[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PULL 18/23] os-posix: reorder parent notification for -d
From: |
Michael Tokarev |
Subject: |
[Qemu-trivial] [PULL 18/23] os-posix: reorder parent notification for -daemonize |
Date: |
Sun, 2 Nov 2014 14:57:30 +0300 |
Put "success" parent reporting in os_setup_post() to after
all other initializers which may also fail, to the very end,
so more possible failure cases are reported properly to the
calling process.
Signed-off-by: Michael Tokarev <address@hidden>
Reviewed-by: Gonglei <address@hidden>
---
os-posix.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/os-posix.c b/os-posix.c
index 52e9897..ba091f1 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -255,15 +255,6 @@ void os_setup_post(void)
int fd = 0;
if (daemonize) {
- uint8_t status = 0;
- ssize_t len;
-
- do {
- len = write(daemon_pipe, &status, 1);
- } while (len < 0 && errno == EINTR);
- if (len != 1) {
- exit(1);
- }
if (chdir("/")) {
perror("not able to chdir to /");
exit(1);
@@ -278,11 +269,21 @@ void os_setup_post(void)
change_process_uid();
if (daemonize) {
+ uint8_t status = 0;
+ ssize_t len;
+
dup2(fd, 0);
dup2(fd, 1);
dup2(fd, 2);
close(fd);
+
+ do {
+ len = write(daemon_pipe, &status, 1);
+ } while (len < 0 && errno == EINTR);
+ if (len != 1) {
+ exit(1);
+ }
}
}
--
1.7.10.4
- [Qemu-trivial] [PULL 07/23] util: Improve os_mem_prealloc error message, (continued)
- [Qemu-trivial] [PULL 07/23] util: Improve os_mem_prealloc error message, Michael Tokarev, 2014/11/02
- [Qemu-trivial] [PULL 05/23] target-arm: A64: remove redundant store, Michael Tokarev, 2014/11/02
- [Qemu-trivial] [PULL 06/23] sparse: fix build, Michael Tokarev, 2014/11/02
- [Qemu-trivial] [PULL 08/23] Revert "os-posix: report error message when lock file failed", Michael Tokarev, 2014/11/02
- [Qemu-trivial] [PULL 23/23] vdi: wrapped uuid_unparse() in #ifdef, Michael Tokarev, 2014/11/02
- [Qemu-trivial] [PULL 09/23] net/slirp: specify logbase for smbd, Michael Tokarev, 2014/11/02
- [Qemu-trivial] [PULL 15/23] os-posix: use global daemon_pipe instead of cryptic fds[1], Michael Tokarev, 2014/11/02
- [Qemu-trivial] [PULL 22/23] tap: fix possible fd leak in net_init_tap, Michael Tokarev, 2014/11/02
- [Qemu-trivial] [PULL 13/23] virtio-9p-proxy: improve error messages in connect_namedsocket(), Michael Tokarev, 2014/11/02
- [Qemu-trivial] [PULL 21/23] tap: do not close(fd) in net_init_tap_one, Michael Tokarev, 2014/11/02
- [Qemu-trivial] [PULL 18/23] os-posix: reorder parent notification for -daemonize,
Michael Tokarev <=
- [Qemu-trivial] [PULL 10/23] target-tricore: check return value before using it, Michael Tokarev, 2014/11/02
- [Qemu-trivial] [PULL 20/23] target-i386: Remove unused model_features_t struct, Michael Tokarev, 2014/11/02
- [Qemu-trivial] [PULL 19/23] tap_int.h: remove repeating NETWORK_SCRIPT defines, Michael Tokarev, 2014/11/02
- [Qemu-trivial] [PULL 16/23] os-posix: replace goto again with a proper loop, Michael Tokarev, 2014/11/02
- [Qemu-trivial] [PULL 14/23] dump: Fix dump-guest-memory termination and use-after-close, Michael Tokarev, 2014/11/02
- Re: [Qemu-trivial] [Qemu-devel] [PULL 00/23] Trivial patches for 2014-11-02, Peter Maydell, 2014/11/03