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

Diff of /trunk/src/runscript.c

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

Revision 2649 Revision 2650
197} 197}
198 198
199static void cleanup (void) 199static void cleanup (void)
200{ 200{
201 /* Flush our buffered output if any */ 201 /* Flush our buffered output if any */
202 eflush (); 202 eclose ();
203 203
204 if (hook_out) 204 if (hook_out)
205 rc_plugin_run (hook_out, applet); 205 rc_plugin_run (hook_out, applet);
206 rc_plugin_unload (); 206 rc_plugin_unload ();
207 207
264} 264}
265 265
266static bool svc_exec (const char *service, const char *arg1, const char *arg2) 266static bool svc_exec (const char *service, const char *arg1, const char *arg2)
267{ 267{
268 bool retval; 268 bool retval;
269
270 /* To ensure any output has hit our ebuffer */
271 fflush (stdout);
272 fflush (stderr);
269 273
270 /* We need to disable our child signal handler now so we block 274 /* We need to disable our child signal handler now so we block
271 until our script returns. */ 275 until our script returns. */
272 signal (SIGCHLD, NULL); 276 signal (SIGCHLD, NULL);
273 277
464 services = rc_get_depends (deptree, types, svclist, 468 services = rc_get_depends (deptree, types, svclist,
465 softlevel, depoptions); 469 softlevel, depoptions);
466 STRLIST_FOREACH (services, svc, i) 470 STRLIST_FOREACH (services, svc, i)
467 if (rc_service_state (svc, rc_service_stopped)) { 471 if (rc_service_state (svc, rc_service_stopped)) {
468 pid_t pid = rc_start_service (svc); 472 pid_t pid = rc_start_service (svc);
469 if (! rc_is_env ("RC_PARALLEL_STARTUP", "yes")) 473 if (! rc_is_env ("RC_PARALLEL", "yes"))
470 rc_waitpid (pid); 474 rc_waitpid (pid);
471 } 475 }
472 476
473 rc_strlist_free (services); 477 rc_strlist_free (services);
474 } 478 }
668 rc_wait_service (svc); 672 rc_wait_service (svc);
669 if (rc_service_state (svc, rc_service_started) || 673 if (rc_service_state (svc, rc_service_started) ||
670 rc_service_state (svc, rc_service_inactive)) 674 rc_service_state (svc, rc_service_inactive))
671 { 675 {
672 pid_t pid = rc_stop_service (svc); 676 pid_t pid = rc_stop_service (svc);
673 if (! rc_is_env ("RC_PARALLEL_STARTUP", "yes")) 677 if (! rc_is_env ("RC_PARALLEL", "yes"))
674 rc_waitpid (pid); 678 rc_waitpid (pid);
675 tmplist = rc_strlist_add (tmplist, svc); 679 tmplist = rc_strlist_add (tmplist, svc);
676 } 680 }
677 } 681 }
678 } 682 }
881 } 885 }
882 886
883 softlevel = rc_get_runlevel (); 887 softlevel = rc_get_runlevel ();
884 888
885 /* If not called from RC or another service then don't be parallel */ 889 /* If not called from RC or another service then don't be parallel */
886 unsetenv ("RC_PARALLEL_STARTUP"); 890 unsetenv ("RC_PARALLEL");
887 } 891 }
888 892
889 setenv ("RC_ELOG", service, 1); 893 setenv ("RC_ELOG", service, 1);
890 setenv ("SVCNAME", applet, 1); 894 setenv ("SVCNAME", applet, 1);
891 895
893 subshells the init script may create so that our mark_service_* 897 subshells the init script may create so that our mark_service_*
894 functions can always instruct us of this change */ 898 functions can always instruct us of this change */
895 snprintf (pid, sizeof (pid), "%d", (int) getpid ()); 899 snprintf (pid, sizeof (pid), "%d", (int) getpid ());
896 setenv ("RC_RUNSCRIPT_PID", pid, 1); 900 setenv ("RC_RUNSCRIPT_PID", pid, 1);
897 901
898 if (rc_is_env ("RC_PARALLEL_STARTUP", "yes")) { 902 if (rc_is_env ("RC_PARALLEL", "yes")) {
899 char ebname[PATH_MAX]; 903 char ebname[PATH_MAX];
900 char *eb; 904 char *eb;
901 905
902 snprintf (ebname, sizeof (ebname), "%s.%s", applet, pid); 906 snprintf (ebname, sizeof (ebname), "%s.%s", applet, pid);
903 eb = rc_strcatpaths (RC_SVCDIR "ebuffer", ebname, (char *) NULL); 907 eb = rc_strcatpaths (RC_SVCDIR "ebuffer", ebname, (char *) NULL);
904 setenv ("RC_EBUFFER", eb, 1); 908 ebuffer (eb);
905 free (eb); 909 free (eb);
906 } 910 }
907 911
908#ifdef __linux__ 912#ifdef __linux__
909 /* Ok, we are ready to go, so setup selinux if applicable */ 913 /* Ok, we are ready to go, so setup selinux if applicable */

Legend:
Removed from v.2649  
changed lines
  Added in v.2650

  ViewVC Help
Powered by ViewVC 1.1.20