(process_cleanup): New function
Showing
1 changed file
with
15 additions
and
5 deletions
... | @@ -17,17 +17,27 @@ | ... | @@ -17,17 +17,27 @@ |
17 | 17 | ||
18 | #include "pop3d.h" | 18 | #include "pop3d.h" |
19 | 19 | ||
20 | RETSIGTYPE | 20 | static int need_cleanup = 0; |
21 | pop3d_sigchld (int signo ARG_UNUSED) | 21 | |
22 | void | ||
23 | process_cleanup () | ||
22 | { | 24 | { |
23 | pid_t pid; | 25 | pid_t pid; |
24 | int status; | 26 | int status; |
25 | 27 | ||
26 | while ( (pid = waitpid(-1, &status, WNOHANG)) > 0) | 28 | if (need_cleanup) |
29 | { | ||
30 | need_cleanup = 0; | ||
31 | while ( (pid = waitpid (-1, &status, WNOHANG)) > 0) | ||
27 | --children; | 32 | --children; |
33 | } | ||
34 | } | ||
35 | |||
36 | RETSIGTYPE | ||
37 | pop3d_sigchld (int signo ARG_UNUSED) | ||
38 | { | ||
39 | need_cleanup = 1; | ||
28 | #ifndef HAVE_SIGACTION | 40 | #ifndef HAVE_SIGACTION |
29 | /* On some system, signal implements the unreliable semantic and | ||
30 | has to be rearm. */ | ||
31 | signal (signo, pop3d_sigchld); | 41 | signal (signo, pop3d_sigchld); |
32 | #endif | 42 | #endif |
33 | } | 43 | } | ... | ... |
-
Please register or sign in to post a comment