diff options
author | netblue30 <netblue30@yahoo.com> | 2017-02-21 10:03:59 -0500 |
---|---|---|
committer | netblue30 <netblue30@yahoo.com> | 2017-02-21 10:03:59 -0500 |
commit | b74d3870246ce03aaff4a1c40867f10aa9d87267 (patch) | |
tree | 74d9402cfbf4d396890694019f5434c5e1674298 /src | |
parent | Merge pull request #1108 from Fred-Barclay/thunar (diff) | |
download | firejail-b74d3870246ce03aaff4a1c40867f10aa9d87267.tar.gz firejail-b74d3870246ce03aaff4a1c40867f10aa9d87267.tar.zst firejail-b74d3870246ce03aaff4a1c40867f10aa9d87267.zip |
merge #1100 from zackw: wait_for_other function rewrite
Diffstat (limited to 'src')
-rw-r--r-- | src/firejail/util.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/firejail/util.c b/src/firejail/util.c index fbb0a1e87..9b9308670 100644 --- a/src/firejail/util.c +++ b/src/firejail/util.c | |||
@@ -605,16 +605,37 @@ void wait_for_other(int fd) { | |||
605 | *ptr = '\0'; | 605 | *ptr = '\0'; |
606 | } | 606 | } |
607 | else { | 607 | else { |
608 | fprintf(stderr, "Error: cannot establish communication with the parent, exiting...\n"); | 608 | fprintf(stderr, "Error: proc %d cannot sync with peer: %s\n", |
609 | getpid(), ferror(stream) ? strerror(errno) : "unexpected EOF"); | ||
610 | |||
611 | int status = 0; | ||
612 | pid_t pid = wait(&status); | ||
613 | if (pid != -1) { | ||
614 | if (WIFEXITED(status)) | ||
615 | fprintf(stderr, "Peer %d unexpectedly exited with status %d\n", | ||
616 | pid, WEXITSTATUS(status)); | ||
617 | else if (WIFSIGNALED(status)) | ||
618 | fprintf(stderr, "Peer %d unexpectedly killed (%s)\n", | ||
619 | pid, strsignal(WTERMSIG(status))); | ||
620 | else | ||
621 | fprintf(stderr, "Peer %d unexpectedly exited " | ||
622 | "(un-decodable wait status %04x)\n", pid, status); | ||
623 | } | ||
609 | exit(1); | 624 | exit(1); |
610 | } | 625 | } |
626 | |||
611 | if (strcmp(childstr, "arg_noroot=0") == 0) | 627 | if (strcmp(childstr, "arg_noroot=0") == 0) |
612 | arg_noroot = 0; | 628 | arg_noroot = 0; |
629 | else if (strcmp(childstr, "arg_noroot=1") == 0) | ||
630 | arg_noroot = 1; | ||
631 | else { | ||
632 | fprintf(stderr, "Error: unexpected message from peer: %s\n", childstr); | ||
633 | exit(1); | ||
634 | } | ||
613 | 635 | ||
614 | fclose(stream); | 636 | fclose(stream); |
615 | } | 637 | } |
616 | 638 | ||
617 | |||
618 | void notify_other(int fd) { | 639 | void notify_other(int fd) { |
619 | FILE* stream; | 640 | FILE* stream; |
620 | int newfd = dup(fd); | 641 | int newfd = dup(fd); |