@@ -219,19 +219,32 @@ int system_strnumcmp(M2_string s,M2_string t) {
219
219
}
220
220
221
221
int fix_status (int status ) {
222
- /* We can't handle status codes bigger than 127 if the shell intervenes. */
223
- return
224
- status == ERROR ? ERROR :
225
- WIFSIGNALED (status ) ? /* whether the process died due to a signal */
226
- WTERMSIG (status ) + (WCOREDUMP (status ) ? 128 : 0 ) : /* signal number n, plus 128 if core was dumped */
227
- WIFEXITED (status ) ? /* whether the process exited */
228
- (
229
- ((WEXITSTATUS (status ) & 0x80 ) != 0 ) ? /* whether /bin/sh indicates a signal in a command */
230
- (WEXITSTATUS (status ) & 0x7f ) : /* the signal number */
231
- (WEXITSTATUS (status ) << 8 ) /* status code times 256 */
232
- ) :
233
- -2 ; /* still running (or stopped) */
234
- }
222
+ /* We can't handle status codes bigger than 127 if the shell intervenes. */
223
+ if (status == ERROR )
224
+ return ERROR ;
225
+ /* whether the process died due to a signal */
226
+ else if (WIFSIGNALED (status )) {
227
+ #ifdef WCOREDUMP
228
+ /* signal number n, plus 128 if core was dumped */
229
+ return WTERMSIG (status ) + (WCOREDUMP (status ) ? 128 : 0 );
230
+ #else
231
+ return WTERMSIG (status );
232
+ #endif
233
+ }
234
+ /* whether the process exited */
235
+ else if (WIFEXITED (status )) {
236
+ /* whether /bin/sh indicates a signal in a command */
237
+ if ((WEXITSTATUS (status ) & 0x80 ) != 0 )
238
+ /* the signal number */
239
+ return WEXITSTATUS (status ) & 0x7f ;
240
+ else
241
+ /* status code times 256 */
242
+ return WEXITSTATUS (status ) << 8 ;
243
+ }
244
+ else
245
+ /* still running (or stopped) */
246
+ return -2 ;
247
+ }
235
248
236
249
M2_arrayint system_waitNoHang (M2_arrayint pids )
237
250
{
0 commit comments