/[baselayout]/trunk/src/librc.c
Gentoo

Diff of /trunk/src/librc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2638 Revision 2641
443static pid_t _exec_service (const char *service, const char *arg) 443static pid_t _exec_service (const char *service, const char *arg)
444{ 444{
445 char *file; 445 char *file;
446 char *fifo; 446 char *fifo;
447 pid_t pid = -1; 447 pid_t pid = -1;
448 pid_t savedpid;
449 int status;
450 char *svc; 448 char *svc;
451 449
452 file = rc_resolve_service (service); 450 file = rc_resolve_service (service);
453 if (! rc_is_file (file)) { 451 if (! rc_is_file (file)) {
454 rc_mark_service (service, rc_service_stopped); 452 rc_mark_service (service, rc_service_stopped);
481 } 479 }
482 480
483 free (fifo); 481 free (fifo);
484 free (file); 482 free (file);
485 483
486 if (pid == -1) { 484 if (pid == -1)
487 eerror ("vfork: %s", strerror (errno)); 485 eerror ("vfork: %s", strerror (errno));
486
488 return (pid); 487 return (pid);
489 } 488}
490 489
491 if (rc_is_env ("RC_PARALLEL_STARTUP", "yes")) 490int rc_waitpid (pid_t pid) {
492 return (pid); 491 int status = 0;
493
494 savedpid = pid; 492 pid_t savedpid = pid;
493
495 errno = 0; 494 errno = 0;
496 do { 495 do {
497 pid = waitpid (savedpid, &status, 0); 496 pid = waitpid (savedpid, &status, 0);
498 if (pid < 0) { 497 if (pid < 0) {
499 if (errno != ECHILD) 498 if (errno != ECHILD)
500 eerror ("waitpid %d: %s", savedpid, strerror (errno)); 499 eerror ("waitpid %d: %s", savedpid, strerror (errno));
501 return (-1); 500 return (-1);
502 } 501 }
503 } while (! WIFEXITED (status) && ! WIFSIGNALED (status)); 502 } while (! WIFEXITED (status) && ! WIFSIGNALED (status));
504 503
505 return (0); 504 return (WIFEXITED (status) ? WEXITSTATUS (status) : EXIT_FAILURE);
506} 505}
507 506
508pid_t rc_stop_service (const char *service) 507pid_t rc_stop_service (const char *service)
509{ 508{
510 if (rc_service_state (service, rc_service_stopped)) 509 if (rc_service_state (service, rc_service_stopped))

Legend:
Removed from v.2638  
changed lines
  Added in v.2641

  ViewVC Help
Powered by ViewVC 1.1.20