trivial-httpd: use PR_SET_PDEATHSIG by default
If we're not daemonizing, this is a useful way to ensure we go away if our parent does. https://bugzilla.gnome.org/show_bug.cgi?id=741264
This commit is contained in:
parent
e908ebd9b3
commit
f7c926c5e9
|
|
@ -28,6 +28,8 @@
|
|||
#include "otutil.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <signal.h>
|
||||
|
||||
static char *opt_port_file = NULL;
|
||||
static gboolean opt_daemonize;
|
||||
|
|
@ -411,6 +413,21 @@ ostree_builtin_trivial_httpd (int argc, char **argv, GCancellable *cancellable,
|
|||
fclose (stdout);
|
||||
fclose (stdin);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Since we're used for testing purposes, let's just do this by
|
||||
* default. This ensures we exit when our parent does.
|
||||
*/
|
||||
if (prctl (PR_SET_PDEATHSIG, SIGTERM) != 0)
|
||||
{
|
||||
int errsv = errno;
|
||||
if (errsv != ENOSYS)
|
||||
{
|
||||
ot_util_set_error_from_errno (error, errsv);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app->running = TRUE;
|
||||
if (opt_autoexit)
|
||||
|
|
|
|||
Loading…
Reference in New Issue