Mercurial > hg > xemacs-beta
comparison src/process.c @ 155:43dd3413c7c7 r20-3b4
Import from CVS: tag r20-3b4
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:39:39 +0200 |
parents | 25f70ba0133c |
children | 3bb7ccffb0c0 |
comparison
equal
deleted
inserted
replaced
154:94141801dd7e | 155:43dd3413c7c7 |
---|---|
2204 | 2204 |
2205 /* Compute the Lisp form of the process status from | 2205 /* Compute the Lisp form of the process status from |
2206 the numeric status that was returned by `wait'. */ | 2206 the numeric status that was returned by `wait'. */ |
2207 | 2207 |
2208 static void | 2208 static void |
2209 update_status_from_wait_code (struct Lisp_Process *p, WAITTYPE *w_fmh) | 2209 update_status_from_wait_code (struct Lisp_Process *p, int *w_fmh) |
2210 { | 2210 { |
2211 /* C compiler lossage when attempting to pass w directly */ | 2211 /* C compiler lossage when attempting to pass w directly */ |
2212 WAITTYPE w = *w_fmh; | 2212 int w = *w_fmh; |
2213 | 2213 |
2214 if (WIFSTOPPED (w)) | 2214 if (WIFSTOPPED (w)) |
2215 { | 2215 { |
2216 p->status_symbol = Qstop; | 2216 p->status_symbol = Qstop; |
2217 p->exit_code = WSTOPSIG (w); | 2217 p->exit_code = WSTOPSIG (w); |
2218 p->core_dumped = 0; | 2218 p->core_dumped = 0; |
2219 } | 2219 } |
2220 else if (WIFEXITED (w)) | 2220 else if (WIFEXITED (w)) |
2221 { | 2221 { |
2222 p->status_symbol = Qexit; | 2222 p->status_symbol = Qexit; |
2223 p->exit_code = WRETCODE (w); | 2223 p->exit_code = WEXITSTATUS (w); |
2224 p->core_dumped = ((WCOREDUMP (w)) ? 1 : 0); | 2224 p->core_dumped = 0; |
2225 } | 2225 } |
2226 else if (WIFSIGNALED (w)) | 2226 else if (WIFSIGNALED (w)) |
2227 { | 2227 { |
2228 p->status_symbol = Qsignal; | 2228 p->status_symbol = Qsignal; |
2229 p->exit_code = (int) WTERMSIG (w); | 2229 p->exit_code = WTERMSIG (w); |
2230 p->core_dumped = ((WCOREDUMP (w)) ? 1 : 0); | 2230 p->core_dumped = WCOREDUMP (w); |
2231 } | 2231 } |
2232 else | 2232 else |
2233 { | 2233 { |
2234 p->status_symbol = Qrun; | 2234 p->status_symbol = Qrun; |
2235 p->exit_code = 0; | 2235 p->exit_code = 0; |
2251 | 2251 |
2252 #ifdef SIGCHLD | 2252 #ifdef SIGCHLD |
2253 | 2253 |
2254 #define MAX_EXITED_PROCESSES 1000 | 2254 #define MAX_EXITED_PROCESSES 1000 |
2255 static volatile pid_t exited_processes[MAX_EXITED_PROCESSES]; | 2255 static volatile pid_t exited_processes[MAX_EXITED_PROCESSES]; |
2256 static volatile WAITTYPE exited_processes_status[MAX_EXITED_PROCESSES]; | 2256 static volatile int exited_processes_status[MAX_EXITED_PROCESSES]; |
2257 static volatile int exited_processes_index; | 2257 static volatile int exited_processes_index; |
2258 | 2258 |
2259 static volatile int sigchld_happened; | 2259 static volatile int sigchld_happened; |
2260 | 2260 |
2261 /* For any processes that have changed status and are recorded | 2261 /* For any processes that have changed status and are recorded |
2280 EMACS_BLOCK_SIGNAL (SIGCHLD); | 2280 EMACS_BLOCK_SIGNAL (SIGCHLD); |
2281 #endif | 2281 #endif |
2282 for (i = 0; i < exited_processes_index; i++) | 2282 for (i = 0; i < exited_processes_index; i++) |
2283 { | 2283 { |
2284 int pid = exited_processes[i]; | 2284 int pid = exited_processes[i]; |
2285 WAITTYPE w = exited_processes_status[i]; | 2285 int w = exited_processes_status[i]; |
2286 | 2286 |
2287 /* Find the process that signaled us, and record its status. */ | 2287 /* Find the process that signaled us, and record its status. */ |
2288 | 2288 |
2289 p = 0; | 2289 p = 0; |
2290 { | 2290 { |
2329 { /* Set the global sync process status variables. */ | 2329 { /* Set the global sync process status variables. */ |
2330 synch_process_alive = 0; | 2330 synch_process_alive = 0; |
2331 | 2331 |
2332 /* Report the status of the synchronous process. */ | 2332 /* Report the status of the synchronous process. */ |
2333 if (WIFEXITED (w)) | 2333 if (WIFEXITED (w)) |
2334 synch_process_retcode = WRETCODE (w); | 2334 synch_process_retcode = WEXITSTATUS (w); |
2335 else if (WIFSIGNALED (w)) | 2335 else if (WIFSIGNALED (w)) |
2336 synch_process_death = signal_name (WTERMSIG (w)); | 2336 synch_process_death = signal_name (WTERMSIG (w)); |
2337 } | 2337 } |
2338 } | 2338 } |
2339 } | 2339 } |
2369 #endif | 2369 #endif |
2370 | 2370 |
2371 while (sigchld_happened) | 2371 while (sigchld_happened) |
2372 { | 2372 { |
2373 int pid; | 2373 int pid; |
2374 WAITTYPE w; | 2374 int w; |
2375 | 2375 |
2376 /* Keep trying to get a status until we get a definitive result. */ | 2376 /* Keep trying to get a status until we get a definitive result. */ |
2377 do | 2377 do |
2378 { | 2378 { |
2379 errno = 0; | 2379 errno = 0; |
2551 #ifdef HAVE_WAITPID | 2551 #ifdef HAVE_WAITPID |
2552 /* #### extra check for terminated processes, in case a SIGCHLD | 2552 /* #### extra check for terminated processes, in case a SIGCHLD |
2553 got missed (this seems to happen sometimes, I'm not sure why). | 2553 got missed (this seems to happen sometimes, I'm not sure why). |
2554 */ | 2554 */ |
2555 { | 2555 { |
2556 WAITTYPE w; | 2556 int w; |
2557 #ifdef SIGCHLD | 2557 #ifdef SIGCHLD |
2558 EMACS_BLOCK_SIGNAL (SIGCHLD); | 2558 EMACS_BLOCK_SIGNAL (SIGCHLD); |
2559 #endif | 2559 #endif |
2560 if (INTP (p->pid) && | 2560 if (INTP (p->pid) && |
2561 waitpid (XINT (p->pid), &w, WNOHANG) == XINT (p->pid)) | 2561 waitpid (XINT (p->pid), &w, WNOHANG) == XINT (p->pid)) |