View | Details | Raw Unified | Return to bug 212829
Collapse All | Expand All

(-)b/daemon.c (-5 / +17 lines)
Lines 55-68 main(int argc, char *argv[]) Link Here
55
{
55
{
56
	struct pidfh  *ppfh, *pfh;
56
	struct pidfh  *ppfh, *pfh;
57
	sigset_t mask, oldmask;
57
	sigset_t mask, oldmask;
58
	int ch, nochdir, noclose, restart, serrno;
58
	int ch, nochdir, noclose, nohup, restart, serrno;
59
	const char *pidfile, *ppidfile, *title, *user;
59
	const char *pidfile, *ppidfile, *title, *user;
60
	pid_t otherpid, pid;
60
	pid_t otherpid, pid;
61
61
62
	nochdir = noclose = 1;
62
	nochdir = noclose = 1;
63
	restart = 0;
63
	restart = nohup = 0 ;
64
	ppidfile = pidfile = title = user = NULL;
64
	ppidfile = pidfile = title = user = NULL;
65
	while ((ch = getopt(argc, argv, "cfp:P:rt:u:")) != -1) {
65
	while ((ch = getopt(argc, argv, "cfp:P:rt:u:H")) != -1) {
66
		switch (ch) {
66
		switch (ch) {
67
		case 'c':
67
		case 'c':
68
			nochdir = 0;
68
			nochdir = 0;
Lines 85-90 main(int argc, char *argv[]) Link Here
85
		case 'u':
85
		case 'u':
86
			user = optarg;
86
			user = optarg;
87
			break;
87
			break;
88
		case 'H':
89
			nohup = 1;
90
			break;
88
		default:
91
		default:
89
			usage();
92
			usage();
90
		}
93
		}
Lines 165-170 main(int argc, char *argv[]) Link Here
165
		sigemptyset(&mask);
168
		sigemptyset(&mask);
166
		sigaddset(&mask, SIGTERM);
169
		sigaddset(&mask, SIGTERM);
167
		sigaddset(&mask, SIGCHLD);
170
		sigaddset(&mask, SIGCHLD);
171
		if (nohup) {
172
			sigaddset(&mask, SIGHUP);
173
		}
168
		if (sigprocmask(SIG_SETMASK, &mask, &oldmask) == -1) {
174
		if (sigprocmask(SIG_SETMASK, &mask, &oldmask) == -1) {
169
			warn("sigprocmask");
175
			warn("sigprocmask");
170
			goto exit;
176
			goto exit;
Lines 265-271 wait_child(pid_t pid, sigset_t *mask) Link Here
265
				return (-1);
271
				return (-1);
266
			}
272
			}
267
			continue;
273
			continue;
268
		default:
274
		case SIGHUP:
275
			if (nohup) {}
276
			if (kill(pid, signo) == -1) {
277
				warn("hup");
278
				return (-1);
279
			}
280
			continue;		default:
269
			warnx("sigwaitinfo: invalid signal: %d", signo);
281
			warnx("sigwaitinfo: invalid signal: %d", signo);
270
			return (-1);
282
			return (-1);
271
		}
283
		}
Lines 276-282 static void Link Here
276
usage(void)
288
usage(void)
277
{
289
{
278
	(void)fprintf(stderr, "%s\n\t%s\n",
290
	(void)fprintf(stderr, "%s\n\t%s\n",
279
	    "usage: daemon [-cfr] [-p child_pidfile] [-P supervisor_pidfile]",
291
	    "usage: daemon [-cfrH] [-p child_pidfile] [-P supervisor_pidfile]",
280
	    "[-t title] [-u user] command arguments ...");
292
	    "[-t title] [-u user] command arguments ...");
281
	exit(1);
293
	exit(1);
282
}
294
}

Return to bug 212829