Skip to content

Commit

Permalink
feat: read snapshot from fd
Browse files Browse the repository at this point in the history
  • Loading branch information
mhofman committed Apr 28, 2023
1 parent 1959e1c commit 9d408aa
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion xsnap/sources/xsnap-worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,18 @@ int main(int argc, char* argv[])
}
xsInitializeSharedCluster();
if (argr) {
snapshot.stream = fopen(argv[argr], "rb");
char *path = argv[argr];
if (path[0] == '@') {
int fd = atoi(path + 1);
int tmpfd = dup(fd);
if (tmpfd < 0) {
snapshot.stream = NULL;
} else {
snapshot.stream = fdopen(tmpfd, "rb");
}
} else {
snapshot.stream = fopen(path, "rb");
}
if (snapshot.stream) {
machine = xsReadSnapshot(&snapshot, "xsnap", NULL);
fclose(snapshot.stream);
Expand Down

0 comments on commit 9d408aa

Please sign in to comment.