Page MenuHomeFreeBSD

D38244.id115981.diff
No OneTemporary

D38244.id115981.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,27 @@
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[])
{
@@ -106,7 +128,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,7 +204,7 @@
if (outfd == -1)
err(7, "open");
}
-
+
if (dosyslog)
openlog(logtag, LOG_PID | LOG_NDELAY, logfac);
@@ -619,5 +641,9 @@
" [-l syslog_facility] [-s syslog_priority]\n"
" [-T syslog_tag] [-m output_mask] [-R restart_delay_secs]\n"
"command arguments ...\n");
+
+
+ // TODO: add long opts usage help
+ (void)fprintf(stderr,"");
exit(1);
}

File Metadata

Mime Type
text/plain
Expires
Sat, May 16, 12:15 AM (2 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33103743
Default Alt Text
D38244.id115981.diff (2 KB)

Event Timeline