diff options
Diffstat (limited to 'src/com_start.c')
-rw-r--r-- | src/com_start.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/com_start.c b/src/com_start.c index 5744e39..3a9dffc 100644 --- a/src/com_start.c +++ b/src/com_start.c | |||
@@ -40,15 +40,19 @@ sigchld(int sig) | |||
40 | 40 | ||
41 | int | 41 | int |
42 | timedwaitpid(pid_t pid, int *status) | 42 | timedwaitpid(pid_t pid, int *status) |
43 | { | 43 | { |
44 | struct timeval now, stoptime, ttw; | 44 | struct timeval now, stoptime, ttw; |
45 | int rc = -1; | 45 | int rc = -1; |
46 | SIGHANDLER oldsig; | 46 | struct sigaction act, oldact; |
47 | |||
48 | act.sa_handler = sigchld; | ||
49 | act.sa_flags = 0; | ||
50 | sigemptyset(&act.sa_mask); | ||
51 | sigaction(SIGCHLD, &act, &oldact); | ||
47 | 52 | ||
48 | oldsig = signal(SIGCHLD, sigchld); | ||
49 | gettimeofday(&stoptime, NULL); | 53 | gettimeofday(&stoptime, NULL); |
50 | stoptime.tv_sec += genrc_timeout; | 54 | stoptime.tv_sec += genrc_timeout; |
51 | while (1) { | 55 | while (1) { |
52 | pid_t p; | 56 | pid_t p; |
53 | 57 | ||
54 | p = waitpid(pid, status, WNOHANG); | 58 | p = waitpid(pid, status, WNOHANG); |
@@ -70,13 +74,13 @@ timedwaitpid(pid_t pid, int *status) | |||
70 | system_error(errno, "select"); | 74 | system_error(errno, "select"); |
71 | break; | 75 | break; |
72 | } | 76 | } |
73 | } | 77 | } |
74 | 78 | ||
75 | } | 79 | } |
76 | signal(SIGCHLD, oldsig); | 80 | sigaction(SIGCHLD, &oldact, NULL); |
77 | if (rc) { | 81 | if (rc) { |
78 | kill(pid, SIGKILL); | 82 | kill(pid, SIGKILL); |
79 | } | 83 | } |
80 | return rc; | 84 | return rc; |
81 | } | 85 | } |
82 | 86 | ||