diff options
author | Roy Marples <roy@marples.name> | 2007-07-31 16:05:56 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2007-07-31 16:05:56 +0000 |
commit | c674026f9e5cf9538101ebc5c19d4da973731ad1 (patch) | |
tree | 76c3dd7c0647054d6fff55d5104d1f0977c85c94 /src/rc.c | |
parent | 02fcdeede4d2a14c10a8efcf8edc212b9a085708 (diff) |
All our binaries are now mulicalls into rc, which makes our on disk size
a lot smaller.
Diffstat (limited to 'src/rc.c')
-rw-r--r-- | src/rc.c | 73 |
1 files changed, 46 insertions, 27 deletions
@@ -30,6 +30,7 @@ #include <termios.h> #include <unistd.h> +#include "builtins.h" #include "einfo.h" #include "rc.h" #include "rc-misc.h" @@ -82,35 +83,37 @@ static pidlist_t *service_pids = NULL; static void cleanup (void) { - pidlist_t *pl = service_pids; + if (applet && strcmp (applet, "rc") == 0) { + pidlist_t *pl = service_pids; - rc_plugin_unload (); + rc_plugin_unload (); - if (! rc_in_plugin && termios_orig) { - tcsetattr (fileno (stdin), TCSANOW, termios_orig); - free (termios_orig); - } - - while (pl) { - pidlist_t *p = pl->next; - free (pl); - pl = p; - } + if (! rc_in_plugin && termios_orig) { + tcsetattr (fileno (stdin), TCSANOW, termios_orig); + free (termios_orig); + } - rc_strlist_free (env); - rc_strlist_free (newenv); - rc_strlist_free (coldplugged_services); - rc_strlist_free (stop_services); - rc_strlist_free (start_services); - rc_free_deptree (deptree); - rc_strlist_free (types); + while (pl) { + pidlist_t *p = pl->next; + free (pl); + pl = p; + } - /* Clean runlevel start, stop markers */ - if (! rc_in_plugin) { - if (rc_is_dir (RC_SVCDIR "softscripts.new")) - rc_rm_dir (RC_SVCDIR "softscripts.new", true); - if (rc_is_dir (RC_SVCDIR "softscripts.old")) - rc_rm_dir (RC_SVCDIR "softscripts.old", true); + rc_strlist_free (env); + rc_strlist_free (newenv); + rc_strlist_free (coldplugged_services); + rc_strlist_free (stop_services); + rc_strlist_free (start_services); + rc_free_deptree (deptree); + rc_strlist_free (types); + + /* Clean runlevel start, stop markers */ + if (! rc_in_plugin) { + if (rc_is_dir (RC_SVCDIR "softscripts.new")) + rc_rm_dir (RC_SVCDIR "softscripts.new", true); + if (rc_is_dir (RC_SVCDIR "softscripts.old")) + rc_rm_dir (RC_SVCDIR "softscripts.old", true); + } } free (applet); @@ -695,12 +698,30 @@ int main (int argc, char **argv) char pidstr[6]; int opt; + atexit (cleanup); if (argv[0]) applet = rc_xstrdup (basename (argv[0])); if (! applet) eerrorx ("arguments required"); + /* These used to be programs in their own right, so we shouldn't + * touch argc or argv for them */ + if (strcmp (applet, "env-update") == 0) + exit (env_update (argc, argv)); + else if (strcmp (applet, "fstabinfo") == 0) + exit (fstabinfo (argc, argv)); + else if (strcmp (applet, "mountinfo") == 0) + exit (mountinfo (argc, argv)); + else if (strcmp (applet, "rc-depend") == 0) + exit (rc_depend (argc, argv)); + else if (strcmp (applet, "rc-status") == 0) + exit (rc_status (argc, argv)); + else if (strcmp (applet, "runscript") == 0) + exit (runscript (argc, argv)); + else if (strcmp (applet, "start-stop-daemon") == 0) + exit (start_stop_daemon (argc, argv)); + argc--; argv++; @@ -739,8 +760,6 @@ int main (int argc, char **argv) if (strcmp (applet, "rc" ) != 0) eerrorx ("%s: unknown applet", applet); - atexit (cleanup); - /* Change dir to / to ensure all scripts don't use stuff in pwd */ chdir ("/"); |