1294
1294
* job_child_reaper:
1295
1295
* @data: unused,
1296
* @pid: process that died,
1297
* @killed: whether @pid was killed,
1298
* @status: exit status of @pid or signal that killed it.
1296
* @pid: process that changed,
1297
* @event: event that occurred on the child,
1298
* @status: exit status of process, signal that killed it or ptrace event.
1300
1300
* This callback should be registered with nih_child_add_watch() so that
1301
1301
* when processes associated with jobs die, the structure is updated and
1305
1305
* safe to do as it only acts if the process is linked to a job.
1308
job_child_reaper (void *data,
1308
job_child_reaper (void *data,
1310
NihChildEvents event,
1314
1315
ProcessType process;
1315
1316
int failed = FALSE, stop = FALSE, state = TRUE;
1327
/* Report the death */
1329
case NIH_CHILD_EXITED:
1330
/* Child exited; check status to see whether it exited
1331
* normally (zero) or with a non-zero status.
1334
nih_warn (_("%s (#%u) %s process (%d) "
1335
"terminated with status %d"),
1336
job->config->name, job->id,
1337
process_name (process), pid, status);
1339
nih_info (_("%s (#%u) %s process (%d) "
1341
job->config->name, job->id,
1342
process_name (process), pid);
1345
case NIH_CHILD_KILLED:
1346
case NIH_CHILD_DUMPED:
1347
/* Child was killed by a signal, and maybe dumped core. We
1348
* store the signal value in the higher byte of status (it's
1349
* safe to do that) to distinguish it from a normal exit
1331
1352
sig = nih_signal_to_name (status);
1333
nih_warn (_("%s (#%u) %s process (%d) killed by %s signal"),
1354
nih_warn (_("%s (#%u) %s process (%d) "
1355
"killed by %s signal"),
1334
1356
job->config->name, job->id,
1335
1357
process_name (process), pid, sig);
1337
nih_warn (_("%s (#%u) %s process (%d) killed by signal %d"),
1359
nih_warn (_("%s (#%u) %s process (%d) "
1360
"killed by signal %d"),
1338
1361
job->config->name, job->id,
1339
1362
process_name (process), pid, status);
1342
/* Store the signal value in the higher byte so we can
1343
* distinguish it from a normal exit status.
1346
} else if (status) {
1347
nih_warn (_("%s (#%u) %s process (%d) terminated with status %d"),
1348
job->config->name, job->id,
1349
process_name (process), pid, status);
1351
nih_info (_("%s (#%u) %s process (%d) exited normally"),
1352
job->config->name, job->id,
1353
process_name (process), pid);
1368
nih_assert_not_reached ();
1356
1371
switch (process) {
1375
1390
* it to be failed since we probably caused the termination.
1377
1392
if ((job->goal != JOB_STOP)
1378
&& (killed || status || job->config->respawn))
1393
&& (status || job->config->respawn))
1381
1396
for (size_t i = 0; i < job->config->normalexit_len; i++) {