1 #include "threadimpl.h"
7 static int threadpassfd;
15 fprint(2, "wait: %r\n");
16 else if(WIFEXITED(status))
17 _exit(WEXITSTATUS(status));
18 print("pid %d if %d %d\n", pid, WIFEXITED(status), WEXITSTATUS(status));
32 _threadsetupdaemonize(void)
43 sysfatal("passer pipe: %r");
45 /* hide these somewhere they won't cause harm */
46 if(dup(p[0], 98) < 0 || dup(p[1], 99) < 0)
47 sysfatal("passer pipe dup: %r");
54 if(fcntl(p[0], F_SETFD, 1) < 0 || fcntl(p[1], F_SETFD, 1) < 0)
55 sysfatal("passer pipe pipe fcntl: %r");
57 signal(SIGCHLD, sigpass);
60 sysfatal("passer fork: %r");
65 signal(SIGCHLD, SIG_DFL);
73 for(i=0; i<NSIG; i++){
76 memset(&sa, 0, sizeof sa);
77 sa.sa_handler = sigpass;
78 sa.sa_flags |= SA_RESTART;
79 sigaction(i, &sa, nil);
83 n = read(p[0], buf, sizeof buf-1);
84 if(n == 0) /* program exited */
88 print("passer read: %r\n");
97 if(threadpassfd >= 0){
98 write(threadpassfd, "0", 1);