Fix deadlock bug when daemonizing
Closing stdin et. al breaks the assuption in spawnvem() that a newly opened pipe is not one of the standard file descriptors. This lead to stdout being closed in the child and so we got no output.
This commit is contained in:
parent
80ac98531f
commit
5d8d866fca
|
@ -102,9 +102,9 @@ static void setup_daemon(void) {
|
|||
|
||||
setup_pidfile();
|
||||
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
freopen("/dev/null", "r", stdin);
|
||||
freopen("/dev/null", "w", stdout);
|
||||
freopen("/dev/null", "w", stderr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,9 @@ static void handle_op_message(uint32_t in_type, struct strbuf *in, struct strbuf
|
|||
if (spawnvem(op->path, argv, envp, in, out, 0))
|
||||
fatal("child %s failed", op->path);
|
||||
|
||||
if (!out->len)
|
||||
fatal("no response from op");
|
||||
|
||||
free_env(envp);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue