mirror of
https://github.com/0intro/wmii
synced 2024-11-29 09:03:25 +03:00
31 lines
475 B
C
31 lines
475 B
C
/* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
|
|
* See LICENSE file for license details.
|
|
*/
|
|
#include <sys/wait.h>
|
|
#include <unistd.h>
|
|
#include "util.h"
|
|
|
|
int
|
|
doublefork(void) {
|
|
pid_t pid;
|
|
int status;
|
|
|
|
switch(pid=fork()) {
|
|
case -1:
|
|
fatal("Can't fork(): %r");
|
|
case 0:
|
|
switch(pid=fork()) {
|
|
case -1:
|
|
fatal("Can't fork(): %r");
|
|
case 0:
|
|
return 0;
|
|
default:
|
|
exit(0);
|
|
}
|
|
default:
|
|
waitpid(pid, &status, 0);
|
|
return pid;
|
|
}
|
|
/* NOTREACHED */
|
|
}
|