Page MenuHomeFreeBSD

D38244.id115979.diff
No OneTemporary

D38244.id115979.diff

diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c
--- a/usr.sbin/daemon/daemon.c
+++ b/usr.sbin/daemon/daemon.c
@@ -40,6 +40,7 @@
#include <fcntl.h>
#include <err.h>
#include <errno.h>
+#include <getopt.h>
#include <libutil.h>
#include <login_cap.h>
#include <paths.h>
@@ -82,6 +83,28 @@
static volatile sig_atomic_t terminate = 0, child_gone = 0, pid = 0,
do_log_reopen = 0;
+
+static char *shortopts = "+cfHSp:P:ru:o:s:l:t:l:m:R:T:";
+
+static struct option longopts[] = {
+ { "change-dir", no_argument, NULL, 'c' },
+ { "close-fds", no_argument, NULL, 'f' },
+ { "sighup", no_argument, NULL, 'H' },
+ { "syslog", no_argument, NULL, 'S' },
+ { "output-file", required_argument, NULL, 'o' },
+ { "output-mask", required_argument, NULL, 'm' },
+ { "child-pidfile", required_argument, NULL, 'p' },
+ { "supervisor-pidfile", required_argument, NULL, 'P' },
+ { "restart", no_argument, NULL, 'r' },
+ { "restart-delay", required_argument, NULL, 'R' },
+ { "title", required_argument, NULL, 't' },
+ { "user", required_argument, NULL, 'u' },
+ { "syslog-priority", required_argument, NULL, 's' },
+ { "syslog-facility", required_argument, NULL, 'l' },
+ { "syslog-tag", required_argument, NULL, 'T' },
+ { NULL, 0, NULL, 0 }
+};
+
int
main(int argc, char *argv[])
{
@@ -92,6 +115,7 @@
int pfd[2] = { -1, -1 }, outfd = -1;
int stdmask, logpri, logfac, log_reopen;
struct pidfh *ppfh, *pfh;
+ ppfh = pfh = NULL;
char *p;
memset(&logpar, 0, sizeof(logpar));
@@ -106,7 +130,7 @@
log_reopen = 0;
outfn = NULL;
title = NULL;
- while ((ch = getopt(argc, argv, "cfHSp:P:ru:o:s:l:t:l:m:R:T:")) != -1) {
+ while ((ch = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
switch (ch) {
case 'c':
nochdir = 0;
@@ -182,11 +206,10 @@
if (outfd == -1)
err(7, "open");
}
-
+
if (dosyslog)
openlog(logtag, LOG_PID | LOG_NDELAY, logfac);
- ppfh = pfh = NULL;
/*
* Try to open the pidfile before calling daemon(3),
* to be able to report the error intelligently

File Metadata

Mime Type
text/plain
Expires
Sat, May 16, 9:01 AM (11 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33100579
Default Alt Text
D38244.id115979.diff (2 KB)

Event Timeline