blob: 7a2d68b856f8e054faae578d7d9327e48b2d78c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
--- 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;
|