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

Diff of /trunk/src/runscript.c

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

Revision 3000 Revision 3001
329 } 329 }
330 330
331 return (ret); 331 return (ret);
332} 332}
333 333
334static int wait_pid (pid_t pid)
335{
336 int status = 0;
337 pid_t savedpid = pid;
338 int retval = -1;
339
340 errno = 0;
341 while ((pid = waitpid (savedpid, &status, 0)) > 0) {
342 if (pid == savedpid)
343 retval = WIFEXITED (status) ? WEXITSTATUS (status) : EXIT_FAILURE;
344 }
345
346 return (retval);
347}
348
334static bool svc_exec (const char *arg1, const char *arg2) 349static bool svc_exec (const char *arg1, const char *arg2)
335{ 350{
336 bool execok; 351 bool execok;
337 int fdout = fileno (stdout); 352 int fdout = fileno (stdout);
338 struct termios tt; 353 struct termios tt;
435 signal (SIGWINCH, SIG_IGN); 450 signal (SIGWINCH, SIG_IGN);
436 close (master_tty); 451 close (master_tty);
437 master_tty = -1; 452 master_tty = -1;
438 } 453 }
439 454
440 execok = rc_waitpid (service_pid) == 0 ? true : false; 455 execok = wait_pid (service_pid) == 0 ? true : false;
441 service_pid = 0; 456 service_pid = 0;
442 457
443 return (execok); 458 return (execok);
444} 459}
445 460
616 if (! rc_runlevel_starting ()) { 631 if (! rc_runlevel_starting ()) {
617 STRLIST_FOREACH (use_services, svc, i) 632 STRLIST_FOREACH (use_services, svc, i)
618 if (rc_service_state (svc) & RC_SERVICE_STOPPED) { 633 if (rc_service_state (svc) & RC_SERVICE_STOPPED) {
619 pid_t pid = rc_service_start (svc); 634 pid_t pid = rc_service_start (svc);
620 if (! rc_env_bool ("RC_PARALLEL")) 635 if (! rc_env_bool ("RC_PARALLEL"))
621 rc_waitpid (pid); 636 wait_pid (pid);
622 } 637 }
623 } 638 }
624 639
625 /* Now wait for them to start */ 640 /* Now wait for them to start */
626 rc_strlist_add (&types, "iafter"); 641 rc_strlist_add (&types, "iafter");
847 if (svcs & RC_SERVICE_STARTED || 862 if (svcs & RC_SERVICE_STARTED ||
848 svcs & RC_SERVICE_INACTIVE) 863 svcs & RC_SERVICE_INACTIVE)
849 { 864 {
850 pid_t pid = rc_service_stop (svc); 865 pid_t pid = rc_service_stop (svc);
851 if (! rc_env_bool ("RC_PARALLEL")) 866 if (! rc_env_bool ("RC_PARALLEL"))
852 rc_waitpid (pid); 867 wait_pid (pid);
853 rc_strlist_add (&tmplist, svc); 868 rc_strlist_add (&tmplist, svc);
854 } 869 }
855 } 870 }
856 } 871 }
857 rc_strlist_free (services); 872 rc_strlist_free (services);

Legend:
Removed from v.3000  
changed lines
  Added in v.3001

  ViewVC Help
Powered by ViewVC 1.1.20