fw (1.2.7) experimental; urgency=low
+ * Add --pidfile option.
* Debianization!
-
* Fix data corruption in chan.c.
-
* Support binding to specific addresses for inet sources and targets.
-
* Require (or prevent) privileged incoming connections in ACLs.
-
* Privileged outgoing connections, if started as root, with privilege
separation if requested to drop privileges after initialization.
.SH SYNOPSIS
.
.B fw
-.RB [ \-dlq ]
+.RB [ \-dlpq ]
.RB [ \-f
.IR file ]
.RB [ \-s
.B "\-l, \-\-syslog, \-\-log"
Emit logging information to the system log, rather than standard error.
.TP
+.B "\-p, \-\-pidfile=" file
+Write
+.BR fw 's
+process-id to
+.I file
+during start-up. If
+.B \-d
+is given too, then the process-id is written after forking (obviously).
+.TP
.B "\-q, \-\-quiet"
Don't output any logging information. This option is not recommended
for normal use, although it can make system call traces clearer so I use
scanner sc;
uid_t drop = -1;
gid_t dropg = -1;
+ const char *pidfile = 0;
conffile *cf, **cff = &conffiles;
#define f_bogus 1u
{ "file", OPTF_ARGREQ, 0, 'f' },
{ "fork", 0, 0, 'd' },
{ "daemon", 0, 0, 'd' },
+ { "pidfile", OPTF_ARGREQ, 0, 'p' },
{ "syslog", 0, 0, 'l' },
{ "log", 0, 0, 'l' },
{ "quiet", 0, 0, 'q' },
{ 0, 0, 0, 0 }
};
- int i = mdwopt(argc, argv, "+hvu GO f:dls:g:", opts, 0, 0, 0);
+ int i = mdwopt(argc, argv, "+hvu" "GO" "f:dp:ls:g:", opts, 0, 0, 0);
if (i < 0)
break;
case 'd':
f |= f_fork;
break;
+ case 'p':
+ pidfile = optarg;
+ break;
case 'l':
f |= f_syslog;
break;
if (kid != 0)
_exit(0);
}
+ if (pidfile) {
+ FILE *fp = fopen(pidfile, "w");
+ if (!fp) {
+ die(EXIT_FAILURE, "couldn't create pidfile `%s': %s",
+ pidfile, strerror(errno));
+ }
+ fprintf(fp, "%lu\n", (unsigned long)getpid());
+ if (fflush(fp) || ferror(fp) || fclose(fp)) {
+ die(EXIT_FAILURE, "couldn't write pidfile `%s': %s",
+ pidfile, strerror(errno));
+ }
+ }
if (f & f_syslog) {
flags |= FW_SYSLOG;