From 1959e1c83899f52ef689bd559af329c2f788ac4a Mon Sep 17 00:00:00 2001 From: Mathieu Hofman Date: Thu, 27 Apr 2023 21:25:43 +0000 Subject: [PATCH] feat: write snapshot to fd --- xsnap/sources/xsnap-worker.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/xsnap/sources/xsnap-worker.c b/xsnap/sources/xsnap-worker.c index 78401c8..aa9f4ba 100644 --- a/xsnap/sources/xsnap-worker.c +++ b/xsnap/sources/xsnap-worker.c @@ -537,7 +537,17 @@ int main(int argc, char* argv[]) #endif path = nsbuf + 1; SnapshotStream stream; - stream.file = fopen(path, "wb"); + if (path[0] == '@') { + int fd = atoi(path + 1); + int tmpfd = dup(fd); + if (tmpfd < 0) { + stream.file = NULL; + } else { + stream.file = fdopen(tmpfd, "ab"); + } + } else { + stream.file = fopen(path, "wb"); + } stream.size = 0; if (stream.file) { snapshot.stream = &stream;