| … | |
… | |
| 627 | } |
627 | } |
| 628 | last = pl; |
628 | last = pl; |
| 629 | } |
629 | } |
| 630 | } |
630 | } |
| 631 | |
631 | |
| 632 | static int wait_pid (pid_t pid) |
|
|
| 633 | { |
|
|
| 634 | int status = 0; |
|
|
| 635 | pid_t savedpid = pid; |
|
|
| 636 | int retval = -1; |
|
|
| 637 | |
|
|
| 638 | errno = 0; |
|
|
| 639 | while ((pid = waitpid (savedpid, &status, 0)) > 0) { |
|
|
| 640 | if (pid == savedpid) |
|
|
| 641 | retval = WIFEXITED (status) ? WEXITSTATUS (status) : EXIT_FAILURE; |
|
|
| 642 | } |
|
|
| 643 | |
|
|
| 644 | return (retval); |
|
|
| 645 | } |
|
|
| 646 | |
|
|
| 647 | static void handle_signal (int sig) |
632 | static void handle_signal (int sig) |
| 648 | { |
633 | { |
| 649 | int serrno = errno; |
634 | int serrno = errno; |
| 650 | char signame[10] = { '\0' }; |
635 | char signame[10] = { '\0' }; |
| 651 | pidlist_t *pl; |
636 | pidlist_t *pl; |
| … | |
… | |
| 1221 | |
1206 | |
| 1222 | /* We always stop the service when in these runlevels */ |
1207 | /* We always stop the service when in these runlevels */ |
| 1223 | if (going_down) { |
1208 | if (going_down) { |
| 1224 | pid_t pid = rc_service_stop (service); |
1209 | pid_t pid = rc_service_stop (service); |
| 1225 | if (pid > 0 && ! rc_env_bool ("RC_PARALLEL")) |
1210 | if (pid > 0 && ! rc_env_bool ("RC_PARALLEL")) |
| 1226 | wait_pid (pid); |
1211 | rc_waitpid (pid); |
| 1227 | continue; |
1212 | continue; |
| 1228 | } |
1213 | } |
| 1229 | |
1214 | |
| 1230 | /* If we're in the start list then don't bother stopping us */ |
1215 | /* If we're in the start list then don't bother stopping us */ |
| 1231 | STRLIST_FOREACH (start_services, svc1, j) |
1216 | STRLIST_FOREACH (start_services, svc1, j) |
| … | |
… | |
| 1287 | |
1272 | |
| 1288 | /* After all that we can finally stop the blighter! */ |
1273 | /* After all that we can finally stop the blighter! */ |
| 1289 | if (! found) { |
1274 | if (! found) { |
| 1290 | pid_t pid = rc_service_stop (service); |
1275 | pid_t pid = rc_service_stop (service); |
| 1291 | if (pid > 0 && ! rc_env_bool ("RC_PARALLEL")) |
1276 | if (pid > 0 && ! rc_env_bool ("RC_PARALLEL")) |
| 1292 | wait_pid (pid); |
1277 | rc_waitpid (pid); |
| 1293 | } |
1278 | } |
| 1294 | } |
1279 | } |
| 1295 | |
1280 | |
| 1296 | /* Wait for our services to finish */ |
1281 | /* Wait for our services to finish */ |
| 1297 | wait_for_services (); |
1282 | wait_for_services (); |
| … | |
… | |
| 1383 | /* Remember the pid if we're running in parallel */ |
1368 | /* Remember the pid if we're running in parallel */ |
| 1384 | if ((pid = rc_service_start (service))) |
1369 | if ((pid = rc_service_start (service))) |
| 1385 | add_pid (pid); |
1370 | add_pid (pid); |
| 1386 | |
1371 | |
| 1387 | if (! rc_env_bool ("RC_PARALLEL")) { |
1372 | if (! rc_env_bool ("RC_PARALLEL")) { |
| 1388 | wait_pid (pid); |
1373 | rc_waitpid (pid); |
| 1389 | remove_pid (pid); |
1374 | remove_pid (pid); |
| 1390 | } |
1375 | } |
| 1391 | } |
1376 | } |
| 1392 | } |
1377 | } |
| 1393 | |
1378 | |