mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-03 05:18:24 +03:00
trivial-httpd: Daemonize better
I was trying to debug `test-pull-c`, and typing `Ctrl-C` in gdb ended up sending `SIGINT` to trivial-httpd as well, killing it. Daemonize a bit more properly to avoid this. I also followed the standard `/dev/null` guidelines. Closes: #643 Approved by: jlebon
This commit is contained in:
parent
d9f43cd2fb
commit
2a71afc507
@ -30,6 +30,7 @@
|
||||
#include "otutil.h"
|
||||
|
||||
#include <locale.h>
|
||||
#include <err.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <signal.h>
|
||||
@ -597,9 +598,12 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
goto out;
|
||||
}
|
||||
/* Child, continue */
|
||||
if (setsid () < 0)
|
||||
err (1, "setsid");
|
||||
/* Daemonising: close stdout/stderr so $() et al work on us */
|
||||
fclose (stdout);
|
||||
fclose (stdin);
|
||||
freopen("/dev/null", "r", stdin);
|
||||
freopen("/dev/null", "w", stdout);
|
||||
freopen("/dev/null", "w", stderr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user