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 "otutil.h"
|
||||||
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#include <err.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@ -597,9 +598,12 @@ run (int argc, char **argv, GCancellable *cancellable, GError **error)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
/* Child, continue */
|
/* Child, continue */
|
||||||
|
if (setsid () < 0)
|
||||||
|
err (1, "setsid");
|
||||||
/* Daemonising: close stdout/stderr so $() et al work on us */
|
/* Daemonising: close stdout/stderr so $() et al work on us */
|
||||||
fclose (stdout);
|
freopen("/dev/null", "r", stdin);
|
||||||
fclose (stdin);
|
freopen("/dev/null", "w", stdout);
|
||||||
|
freopen("/dev/null", "w", stderr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user