Mercurial > hg > toybox
comparison toys/pending/dhcp.c @ 1327:85f297591693 draft
Introduce xfork() and make commands use it, and make some WEXITSTATUS() use WIFEXITED() and WTERMSIG()+127.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 31 May 2014 12:33:24 -0500 |
parents | 88abd5b68a17 |
children | e0c9c5424864 |
comparison
equal
deleted
inserted
replaced
1326:78a3eaf5555f | 1327:85f297591693 |
---|---|
316 | 316 |
317 static int dhcp_daemon(void) | 317 static int dhcp_daemon(void) |
318 { | 318 { |
319 int fd = open("/dev/null", O_RDWR); | 319 int fd = open("/dev/null", O_RDWR); |
320 if (fd < 0) fd = xcreate("/", O_RDONLY, 0666); | 320 if (fd < 0) fd = xcreate("/", O_RDONLY, 0666); |
321 pid_t pid = fork(); | 321 |
322 | 322 if (xfork()) exit(0); |
323 if (pid < 0) perror_exit("DAEMON: failed to fork"); | |
324 if (pid) exit(EXIT_SUCCESS); | |
325 | 323 |
326 setsid(); | 324 setsid(); |
327 dup2(fd, 0); | 325 dup2(fd, 0); |
328 dup2(fd, 1); | 326 dup2(fd, 1); |
329 dup2(fd, 2); | 327 dup2(fd, 2); |