--- rarpd.c.orig 2003-11-03 22:10:41.000304928 -0500 +++ rarpd.c 2003-11-03 22:13:52.683164704 -0500 @@ -429,12 +429,25 @@ openlog(program_name, syslogflags, LOG_LOCAL1); if (!nofork) { + FILE *pidfile; pid = fork(); - if (pid > 0) exit(0); if (pid < 0) { syslog(LOG_ERR, "%s: fork failed: %s", program_name, strerror(errno)); exit(1); } + if (pid) { + pidfile = fopen("/var/run/rarpd.pid", "w"); + if (pidfile) { + fprintf(pidfile, "%i", pid); + fclose(pidfile); + } else + perror("Could not write pidfile"); + exit(0); + } + chdir("/"); + close(0); + close(1); + close(2); } if (ethers == NULL) ethers = _PATH_ETHERS;