Commit b564c438 authored by Marco d'Itri's avatar Marco d'Itri

Write a PID file

This code was removed upstream because OpenBSD developers do not believe
in PID files.

Closes: #849776
parent a6b8e230
......@@ -13,3 +13,4 @@ print_pause_time
tcp46
buftuning
monotonic_clock
write_pidfile
--- a/inetd.c
+++ b/inetd.c
@@ -289,6 +289,7 @@ void reap(int, short, void *);
void retry(int, short, void *);
void die(int, short, void *);
+void logpid(void);
void spawn(int, short, void *);
void gettcp(int, short, void *);
int setconfig(void);
@@ -412,6 +413,7 @@ main(int argc, char *argv[], char *envp[
}
openlog("inetd", LOG_PID | LOG_NOWAIT, LOG_DAEMON);
+ logpid();
if (getrlimit(RLIMIT_NOFILE, &rlim_nofile) < 0) {
syslog(LOG_ERR, "getrlimit: %m");
@@ -878,6 +880,7 @@ die(int sig, short events, void *arg)
}
(void)close(sep->se_fd);
}
+ (void)unlink("/run/inetd.pid");
exit(0);
}
@@ -1587,6 +1590,17 @@ inetd_setproctitle(char *a, int s)
setproctitle("-%s", a);
}
+void
+logpid(void)
+{
+ FILE *fp;
+
+ if ((fp = fopen("/run/inetd.pid", "w")) != NULL) {
+ fprintf(fp, "%ld\n", (long)getpid());
+ (void)fclose(fp);
+ }
+}
+
int
bump_nofile(void)
{
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment