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

Diff of /trunk/src/runscript.c

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

Revision 2618 Revision 2634
13#include <sys/stat.h> 13#include <sys/stat.h>
14#include <sys/wait.h> 14#include <sys/wait.h>
15#include <dlfcn.h> 15#include <dlfcn.h>
16#include <errno.h> 16#include <errno.h>
17#include <getopt.h> 17#include <getopt.h>
18#include <libgen.h>
18#include <limits.h> 19#include <limits.h>
19#include <stdio.h> 20#include <stdio.h>
20#include <stdlib.h> 21#include <stdlib.h>
21#include <string.h> 22#include <string.h>
22#include <unistd.h> 23#include <unistd.h>
23
24#ifndef __linux__
25#include <libgen.h>
26#endif
27 24
28#include "einfo.h" 25#include "einfo.h"
29#include "rc.h" 26#include "rc.h"
30#include "rc-misc.h" 27#include "rc-misc.h"
31#include "rc-plugin.h" 28#include "rc-plugin.h"
800 STRLIST_FOREACH (restart_services, svc, i) { 797 STRLIST_FOREACH (restart_services, svc, i) {
801 if (rc_service_state (svc, rc_service_stopped)) { 798 if (rc_service_state (svc, rc_service_stopped)) {
802 if (inactive) { 799 if (inactive) {
803 rc_schedule_start_service (service, svc); 800 rc_schedule_start_service (service, svc);
804 ewarn ("WARNING: %s is scheduled to started when %s has started", 801 ewarn ("WARNING: %s is scheduled to started when %s has started",
805 svc, basename (service)); 802 svc, applet);
806 } else 803 } else
807 rc_start_service (svc); 804 rc_start_service (svc);
808 } 805 }
809 } 806 }
810 } 807 }
819 { "quiet", 0, NULL, 'q'}, 816 { "quiet", 0, NULL, 'q'},
820 { "verbose", 0, NULL, 'v'}, 817 { "verbose", 0, NULL, 'v'},
821 { "help", 0, NULL, 'h'}, 818 { "help", 0, NULL, 'h'},
822 { NULL, 0, NULL, 0} 819 { NULL, 0, NULL, 0}
823}; 820};
824#include "_usage.c" 821// #include "_usage.c"
825 822
826int main (int argc, char **argv) 823int main (int argc, char **argv)
827{ 824{
828 const char *service = argv[1]; 825 char *service = argv[1];
829 int i; 826 int i;
830 bool deps = true; 827 bool deps = true;
831 bool doneone = false; 828 bool doneone = false;
832 char pid[16]; 829 char pid[16];
833 int retval; 830 int retval;
838 execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, (char *) NULL); 835 execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, (char *) NULL);
839 eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s", 836 eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s",
840 applet, strerror (errno)); 837 applet, strerror (errno));
841 } 838 }
842 839
843 applet = strdup (basename (service)); 840 applet = rc_xstrdup (basename (service));
844 atexit (cleanup); 841 atexit (cleanup);
845 842
846#ifdef __linux__ 843#ifdef __linux__
847 /* coldplug events can trigger init scripts, but we don't want to run them 844 /* coldplug events can trigger init scripts, but we don't want to run them
848 until after rc sysinit has completed so we punt them to the boot runlevel */ 845 until after rc sysinit has completed so we punt them to the boot runlevel */
954 951
955 /* Save the IN_BACKGROUND env flag so it's ONLY passed to the service 952 /* Save the IN_BACKGROUND env flag so it's ONLY passed to the service
956 that is being called and not any dependents */ 953 that is being called and not any dependents */
957 if (getenv ("IN_BACKGROUND")) { 954 if (getenv ("IN_BACKGROUND")) {
958 in_background = rc_is_env ("IN_BACKGROUND", "true"); 955 in_background = rc_is_env ("IN_BACKGROUND", "true");
959 ibsave = strdup (getenv ("IN_BACKGROUND")); 956 ibsave = rc_xstrdup (getenv ("IN_BACKGROUND"));
960 unsetenv ("IN_BACKGROUND"); 957 unsetenv ("IN_BACKGROUND");
961 } 958 }
962 959
963 if (rc_is_env ("IN_HOTPLUG", "1")) { 960 if (rc_is_env ("IN_HOTPLUG", "1")) {
964 if (! rc_is_env ("RC_HOTPLUG", "yes") || ! rc_allow_plug (applet)) 961 if (! rc_is_env ("RC_HOTPLUG", "yes") || ! rc_allow_plug (applet))

Legend:
Removed from v.2618  
changed lines
  Added in v.2634

  ViewVC Help
Powered by ViewVC 1.1.20