FreeBSD Bugzilla – Attachment 175049 Details for
Bug 212829
daemon(8) using -P swallows signals such as SIGHUP instead of propagating them
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch to daemon.c v1
daemon.c.patch (text/plain), 1.92 KB, created by
Dave Cottlehuber
on 2016-09-22 09:15:50 UTC
(
hide
)
Description:
patch to daemon.c v1
Filename:
MIME Type:
Creator:
Dave Cottlehuber
Created:
2016-09-22 09:15:50 UTC
Size:
1.92 KB
patch
obsolete
>commit 3b3867f76d97f19db41389505954f29400488c4f >Author: Dave Cottlehuber <dch@skunkwerks.at> >Date: Thu Sep 22 11:00:45 2016 +0200 > > add optional flag -H to propagate SIGHUP to child process > >diff --git a/daemon.c b/daemon.c >index 23051fd..2d8bec7 100644 >--- a/daemon.c >+++ b/daemon.c >@@ -55,14 +55,14 @@ main(int argc, char *argv[]) > { > struct pidfh *ppfh, *pfh; > sigset_t mask, oldmask; >- int ch, nochdir, noclose, restart, serrno; >+ int ch, nochdir, noclose, nohup, restart, serrno; > const char *pidfile, *ppidfile, *title, *user; > pid_t otherpid, pid; > > nochdir = noclose = 1; >- restart = 0; >+ restart = nohup = 0 ; > ppidfile = pidfile = title = user = NULL; >- while ((ch = getopt(argc, argv, "cfp:P:rt:u:")) != -1) { >+ while ((ch = getopt(argc, argv, "cfp:P:rt:u:H")) != -1) { > switch (ch) { > case 'c': > nochdir = 0; >@@ -85,6 +85,9 @@ main(int argc, char *argv[]) > case 'u': > user = optarg; > break; >+ case 'H': >+ nohup = 1; >+ break; > default: > usage(); > } >@@ -165,6 +168,9 @@ main(int argc, char *argv[]) > sigemptyset(&mask); > sigaddset(&mask, SIGTERM); > sigaddset(&mask, SIGCHLD); >+ if (nohup) { >+ sigaddset(&mask, SIGHUP); >+ } > if (sigprocmask(SIG_SETMASK, &mask, &oldmask) == -1) { > warn("sigprocmask"); > goto exit; >@@ -265,7 +271,13 @@ wait_child(pid_t pid, sigset_t *mask) > return (-1); > } > continue; >- default: >+ case SIGHUP: >+ if (nohup) {} >+ if (kill(pid, signo) == -1) { >+ warn("hup"); >+ return (-1); >+ } >+ continue; default: > warnx("sigwaitinfo: invalid signal: %d", signo); > return (-1); > } >@@ -276,7 +288,7 @@ static void > usage(void) > { > (void)fprintf(stderr, "%s\n\t%s\n", >- "usage: daemon [-cfr] [-p child_pidfile] [-P supervisor_pidfile]", >+ "usage: daemon [-cfrH] [-p child_pidfile] [-P supervisor_pidfile]", > "[-t title] [-u user] command arguments ..."); > exit(1); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 212829
: 175049