diff options
author | Lennart Poettering <lennart@poettering.net> | 2008-07-28 23:24:56 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2008-07-28 23:24:56 +0200 |
commit | f5477752e18df32571728e36772db1cf1038a7b8 (patch) | |
tree | 7b5b70809e3095deb95b309d213952d698778214 | |
parent | 78d2b0944ba302f7c3026f0aea8dd450ebff8153 (diff) |
add more error checking
-rw-r--r-- | libdaemon/dfork.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libdaemon/dfork.c b/libdaemon/dfork.c index b0a99dc..14d2238 100644 --- a/libdaemon/dfork.c +++ b/libdaemon/dfork.c @@ -298,7 +298,15 @@ pid_t daemon_fork(void) { pid_t dpid; close(pipe_fds[1]); - waitpid(pid, NULL, WUNTRACED); + + if (waitpid(pid, NULL, WUNTRACED) < 0) { + saved_errno = errno; + close(pipe_fds[0]); + sigaction(SIGCHLD, &sa_old, NULL); + sigprocmask(SIG_SETMASK, &ss_old, NULL); + errno = saved_errno; + return -1; + } sigprocmask(SIG_SETMASK, &ss_old, NULL); sigaction(SIGCHLD, &sa_old, NULL); |