Lines 2859-2907
Link Here
|
2859 |
if ((p->kill_how == kill_after_timeout) |
2859 |
if ((p->kill_how == kill_after_timeout) |
2860 |
|| (p->kill_how == kill_only_once)) { |
2860 |
|| (p->kill_how == kill_only_once)) { |
2861 |
/* Subprocess may be dead already. Only need the timeout if not. */ |
2861 |
/* Subprocess may be dead already. Only need the timeout if not. */ |
2862 |
if (ap_os_kill(p->pid, SIGTERM) == -1) { |
2862 |
if (ap_os_kill(p->pid, SIGTERM) != -1) |
2863 |
p->kill_how = kill_never; |
|
|
2864 |
} |
2865 |
else { |
2866 |
need_timeout = 1; |
2863 |
need_timeout = 1; |
2867 |
} |
|
|
2868 |
} |
2864 |
} |
2869 |
else if (p->kill_how == kill_always) { |
2865 |
else if (p->kill_how == kill_always) { |
2870 |
kill(p->pid, SIGKILL); |
2866 |
kill(p->pid, SIGKILL); |
2871 |
} |
2867 |
} |
2872 |
} |
2868 |
} |
2873 |
|
2869 |
|
2874 |
/* Sleep only if we have to. The sleep algorithm grows |
2870 |
/* Sleep only if we have to... */ |
2875 |
* by a factor of two on each iteration. TIMEOUT_INTERVAL |
|
|
2876 |
* is equal to TIMEOUT_USECS / 64. |
2877 |
*/ |
2878 |
if (need_timeout) { |
2879 |
timeout_interval = TIMEOUT_INTERVAL; |
2880 |
tv.tv_sec = 0; |
2881 |
tv.tv_usec = timeout_interval; |
2882 |
ap_select(0, NULL, NULL, NULL, &tv); |
2883 |
|
2871 |
|
2884 |
do { |
2872 |
if (need_timeout) |
2885 |
need_timeout = 0; |
2873 |
sleep(3); |
2886 |
for (p = procs; p; p = p->next) { |
|
|
2887 |
if (p->kill_how == kill_after_timeout) { |
2888 |
if (waitpid(p->pid, (int *) 0, WNOHANG | WUNTRACED) > 0) |
2889 |
p->kill_how = kill_never; |
2890 |
else |
2891 |
need_timeout = 1; |
2892 |
} |
2893 |
} |
2894 |
if (need_timeout) { |
2895 |
if (timeout_interval >= TIMEOUT_USECS) { |
2896 |
break; |
2897 |
} |
2898 |
tv.tv_sec = timeout_interval / 1000000; |
2899 |
tv.tv_usec = timeout_interval % 1000000; |
2900 |
ap_select(0, NULL, NULL, NULL, &tv); |
2901 |
timeout_interval *= 2; |
2902 |
} |
2903 |
} while (need_timeout); |
2904 |
} |
2905 |
|
2874 |
|
2906 |
/* OK, the scripts we just timed out for have had a chance to clean up |
2875 |
/* OK, the scripts we just timed out for have had a chance to clean up |
2907 |
* --- now, just get rid of them, and also clean up the system accounting |
2876 |
* --- now, just get rid of them, and also clean up the system accounting |