source: src/router/rc/rc.c @ 9751

Last change on this file since 9751 was 9751, checked in by BrainSlayer, 5 years ago

use busybox brctl instead of own implementation

File size: 17.5 KB
Line 
1
2#include <stdio.h>
3#include <stdlib.h>
4#include <limits.h>
5#include <time.h>
6#include <unistd.h>
7#include <errno.h>
8#include <syslog.h>
9#include <signal.h>
10#include <string.h>
11#include <sys/klog.h>
12#include <sys/types.h>
13#include <sys/mount.h>
14#include <sys/reboot.h>
15#include <sys/stat.h>
16#include <sys/sysmacros.h>
17#include <sys/time.h>
18#include <sys/utsname.h>
19#include <sys/wait.h>
20#include <dirent.h>
21
22#include <epivers.h>
23#include <bcmnvram.h>
24#include <mtd.h>
25#include <shutils.h>
26#include <rc.h>
27#include <netconf.h>
28#include <nvparse.h>
29#include <bcmdevs.h>
30
31#include <wlutils.h>
32#include <utils.h>
33#include <cyutils.h>
34#include <code_pattern.h>
35#include <cy_conf.h>
36#include <typedefs.h>
37#include <bcmnvram.h>
38#include <bcmutils.h>
39#include <shutils.h>
40#include <wlutils.h>
41#include <cy_conf.h>
42
43#include <revision.h>
44
45
46
47/* States */
48enum
49{
50  RESTART,
51  STOP,
52  START,
53  TIMER,
54  USER,
55  IDLE,
56#ifdef HAVE_X86
57  REBOOT,
58#endif
59};
60static int state = START;
61static int signalled = -1;
62
63/* Signal handling */
64static void
65rc_signal (int sig)
66{
67  if (state == IDLE)
68    {
69      if (sig == SIGHUP)
70        {
71          lcdmessage ("Signal RESTART");
72          printf ("signalling RESTART\n");
73          signalled = RESTART;
74        }
75      else if (sig == SIGUSR2)
76        {
77          lcdmessage ("Signal START");
78          printf ("signalling START\n");
79          signalled = START;
80        }
81      else if (sig == SIGINT)
82        {
83          lcdmessage ("Signal STOP");
84          printf ("signalling STOP\n");
85          signalled = STOP;
86        }
87      else if (sig == SIGALRM)
88        {
89          lcdmessage ("Signal TIMER");
90          printf ("signalling TIMER\n");
91          signalled = TIMER;
92        }
93#ifdef HAVE_X86
94      else if (sig == SIGTERM)
95        {
96          lcdmessage ("Signal Reboot");
97          printf ("signalling REBOOT\n");
98          signalled = REBOOT;
99        }
100#endif
101      else if (sig == SIGUSR1)
102        {                       // Receive from WEB
103          lcdmessage ("Signal USER");
104          printf ("signalling USER1\n");
105          signalled = USER;
106        }
107
108    }
109}
110
111/* Timer procedure */
112int
113do_timer (void)
114{
115  //do_ntp();
116  return 0;
117}
118static int noconsole = 0;
119
120/* Main loop */
121int
122main_loop (int argc, char **argv)
123{
124  sigset_t sigset;
125  pid_t shell_pid = 0;
126  uint boardflags;
127  //setenv("PATH", "/sbin:/bin:/usr/sbin:/usr/bin:/jffs/sbin:/jffs/bin:/jffs/usr/sbin:/jffs/usr/bin", 1);
128  //system("/etc/nvram/nvram");
129  /* Basic initialization */
130  cprintf ("console init\n");
131  if (console_init ())
132    noconsole = 1;
133  cprintf ("init lcd\n");
134  initlcd ();
135  cprintf ("first message\n");
136  lcdmessage ("System Start");
137  cprintf ("start service\n");
138  start_service ("sysinit");
139  cprintf ("setup signals\n");
140  /* Setup signal handlers */
141  signal_init ();
142  signal (SIGHUP, rc_signal);
143  signal (SIGUSR1, rc_signal);  // Start single service from WEB, by honor
144  signal (SIGUSR2, rc_signal);
145  signal (SIGINT, rc_signal);
146  signal (SIGALRM, rc_signal);
147#ifdef HAVE_X86
148  signal (SIGTERM, rc_signal);
149#endif
150  sigemptyset (&sigset);
151
152  /* Give user a chance to run a shell before bringing up the rest of the system */
153
154  if (!noconsole)
155    ddrun_shell (1, 0);
156  cprintf ("setup nvram\n");
157
158  start_service ("nvram");
159
160  /* Restore defaults if necessary */
161  int brand = getRouterBrand ();
162
163#ifdef HAVE_SKYTEL
164  nvram_set ("vlan0ports", "0 1 2 3 4 5*");
165  nvram_set ("vlan1ports", "");
166#else
167
168  if (brand == ROUTER_WRT600N)
169    {
170      nvram_set ("vlan2hwname", "et0");
171    }
172
173
174#endif
175  start_service ("restore_defaults");
176
177
178  /* Add vlan */
179  boardflags = strtoul (nvram_safe_get ("boardflags"), NULL, 0);
180  nvram_set ("wanup", "0");
181
182
183#ifndef HAVE_RB500
184  switch (brand)
185    {
186    case ROUTER_WRT600N:
187    case ROUTER_ASUS_WL500GD:
188    case ROUTER_ASUS_WL550GE:
189    case ROUTER_MOTOROLA:
190    case ROUTER_RT480W:
191    case ROUTER_WRT350N:
192    case ROUTER_BUFFALO_WZRG144NH:
193    case ROUTER_DELL_TRUEMOBILE_2300_V2:
194      start_service ("config_vlan");
195      break;
196    default:
197      if (check_vlan_support ())
198        {
199          start_service ("config_vlan");
200        }
201      break;
202
203    }
204#endif
205
206  set_ip_forward ('1');
207  system ("/etc/preinit");      //sets default values for ip_conntrack
208#ifdef HAVE_JFFS2
209  start_service ("jffs2");
210#endif
211#ifdef HAVE_MMC
212  start_service ("mmc");
213#endif
214
215  start_service ("mkfiles");
216  char *hostname;
217
218  /* set hostname to wan_hostname or router_name */
219  if (strlen (nvram_safe_get ("wan_hostname")) > 0)
220    hostname = nvram_safe_get ("wan_hostname");
221  else if (strlen (nvram_safe_get ("router_name")) > 0)
222    hostname = nvram_safe_get ("router_name");
223  else
224    hostname = "dd-wrt";
225
226  sethostname (hostname, strlen (hostname));
227  stop_service ("httpd");
228
229//create loginprompt
230  FILE *fp = fopen ("/tmp/loginprompt", "wb");
231
232#ifndef HAVE_MAKSAT
233#ifndef HAVE_MSSID
234#ifdef DIST
235  if (strlen (DIST) > 0)
236    fprintf (fp,
237             "DD-WRT v23 SP3 %s (c) 2008 NewMedia-NET GmbH\nRelease: "
238             BUILD_DATE " (SVN revision: %s)\n", DIST, SVN_REVISION);
239  else
240    fprintf (fp,
241             "DD-WRT v23 SP3 custom (c) 2008 NewMedia-NET GmbH\nRelease: "
242             BUILD_DATE " (SVN revision: %s)\n", SVN_REVISION);
243#else
244  fprintf (fp,
245           "DD-WRT v23 SP3 custom (c) 2008 NewMedia-NET GmbH\nRelease: "
246           BUILD_DATE " (SVN revision: %s)\n", SVN_REVISION);
247#endif
248#else
249#ifdef DIST
250  if (strlen (DIST) > 0)
251    fprintf (fp,
252             "DD-WRT v24 %s (c) 2008 NewMedia-NET GmbH\nRelease: " BUILD_DATE
253             " (SVN revision: %s)\n", DIST, SVN_REVISION);
254  else
255    fprintf (fp,
256             "DD-WRT v24 custom (c) 2008 NewMedia-NET GmbH\nRelease: "
257             BUILD_DATE " (SVN revision: %s)\n", SVN_REVISION);
258#else
259  fprintf (fp,
260           "DD-WRT v24 custom (c) 2008 NewMedia-NET GmbH\nRelease: "
261           BUILD_DATE " (SVN revision: %s)\n", SVN_REVISION);
262#endif
263#endif
264#endif
265
266  fclose (fp);
267  /* Loop forever */
268  for (;;)
269    {
270      switch (state)
271        {
272        case USER:              // Restart single service from WEB of tftpd, by honor
273          lcdmessage ("RESTART SERVICES");
274          cprintf ("USER1\n");
275          start_single_service ();
276#ifdef HAVE_CHILLI
277          start_service ("chilli");
278#endif
279#ifdef HAVE_WIFIDOG
280          start_service ("wifidog");
281#endif
282
283          state = IDLE;
284          break;
285
286        case RESTART:
287          lcdmessage ("RESTART SYSTEM");
288#ifdef HAVE_OVERCLOCKING
289          start_service ("overclocking");
290#endif
291          cprintf ("RESET NVRAM VARS\n");
292          nvram_set ("wl0_lazy_wds", nvram_safe_get ("wl_lazy_wds"));
293#ifndef HAVE_MSSID
294          nvram_set ("wl0_akm", nvram_safe_get ("wl_akm"));
295          if (nvram_match ("wl_wep", "tkip"))
296            {
297              nvram_set ("wl_crypto", "tkip");
298            }
299          else if (nvram_match ("wl_wep", "aes"))
300            {
301              nvram_set ("wl_crypto", "aes");
302            }
303          else if (nvram_match ("wl_wep", "tkip+aes"))
304            {
305              nvram_set ("wl_crypto", "tkip+aes");
306            }
307          if (nvram_match ("wl_wep", "restricted"))
308            nvram_set ("wl_wep", "enabled");    // the nas need this value, the "restricted" is no longer need. (20040624 by honor)
309#endif
310
311          cprintf ("RESTART\n");
312
313#ifndef HAVE_MADWIFI
314          eval ("wlconf", nvram_safe_get ("wl0_ifname"), "down");
315#ifdef HAVE_MSSID
316          char *next;
317          char var[80];
318          char *vifs = nvram_safe_get ("wl0_vifs");
319          if (vifs != NULL)
320            foreach (var, vifs, next)
321            {
322              eval ("ifconfig", var, "down");
323            }
324#endif
325#endif
326
327          /* Fall through */
328        case STOP:
329          lcdmessage ("STOPPING SERVICES");
330          cprintf ("STOP\n");
331          killall ("udhcpc", SIGKILL);
332          setenv ("PATH",
333                  "/sbin:/bin:/usr/sbin:/usr/bin:/jffs/sbin:/jffs/bin:/jffs/usr/sbin:/jffs/usr/bin",
334                  1);
335          setenv ("LD_LIBRARY_PATH",
336                  "/lib:/usr/lib:/jffs/lib:/jffs/usr/lib:/mmc/lib:/mmc/usr/lib:",
337                  1);
338          cprintf ("STOP SERVICES\n");
339
340          stop_services ();
341          stop_service ("radio_timer");
342#ifndef HAVE_MADWIFI
343          stop_service ("nas");
344#endif
345          cprintf ("STOP WAN\n");
346          stop_service ("ttraff");
347          stop_service ("wan");
348          cprintf ("STOP LAN\n");
349#ifdef HAVE_MADWIFI
350          stop_service ("stabridge");
351#endif
352#ifdef HAVE_RSTP
353          eval ("killall", "rstpd");
354          unlink ("/tmp/.rstp_server");
355#endif
356#ifdef HAVE_VLANTAGGING
357          stop_service ("bridging");
358#endif
359#ifdef HAVE_BONDING
360          stop_service ("bonding");
361#endif
362
363          stop_service ("lan");
364#ifdef HAVE_VLANTAGGING
365          stop_service ("bridgesif");
366          stop_service ("vlantagging");
367#endif
368
369#ifndef HAVE_RB500
370          stop_service ("resetbutton");
371#endif
372          start_service ("create_rc_shutdown");
373          system ("/tmp/.rc_shutdown");
374          if (state == STOP)
375            {
376              state = IDLE;
377              break;
378            }
379          /* Fall through */
380        case START:
381          lcdmessage ("START SERVICES");
382          nvram_set ("wl0_lazy_wds", nvram_safe_get ("wl_lazy_wds"));
383#ifndef HAVE_MSSID
384          nvram_set ("wl0_akm", nvram_safe_get ("wl_akm"));
385#endif
386          cprintf ("START\n");
387          setenv ("PATH",
388                  "/sbin:/bin:/usr/sbin:/usr/bin:/jffs/sbin:/jffs/bin:/jffs/usr/sbin:/jffs/usr/bin",
389                  1);
390          setenv ("LD_LIBRARY_PATH",
391                  "/lib:/usr/lib:/jffs/lib:/jffs/usr/lib:/mmc/lib:/mmc/usr/lib:",
392                  1);
393#ifdef HAVE_IPV6
394          start_service ("ipv6");
395#endif
396#ifndef HAVE_RB500
397          start_service ("resetbutton");
398#endif
399          start_service ("setup_vlans");
400#ifndef HAVE_MADWIFI
401          if (nvram_match ("wl0_mode", "apstawet"))     //temporary fix for repeater-bridge mode init problem
402            {
403              nvram_set ("wl0_mode", "wet");
404              start_service ("wlconf");
405              eval ("wlconf", nvram_safe_get ("wl0_ifname"), "down");
406              nvram_set ("wl0_mode", "apstawet");
407            }
408          start_service ("wlconf");
409#endif
410
411#ifdef HAVE_VLANTAGGING
412          start_service ("bridging");
413#endif
414          start_service ("lan");
415#ifdef HAVE_BONDING
416          start_service ("bonding");
417#endif
418#ifdef HAVE_REGISTER
419          start_service ("mkfiles");
420#endif
421#ifdef HAVE_MADWIFI
422          start_service ("stabridge");
423#endif
424
425
426          cprintf ("start services\n");
427          start_services ();
428
429          cprintf ("start wan boot\n");
430          start_service ("wan_boot");
431          start_service ("ttraff");
432
433          cprintf ("diag STOP LED\n");
434          diag_led (DIAG, STOP_LED);
435          cprintf ("set led release wan control\n");
436          SET_LED (RELEASE_WAN_CONTROL);
437
438          if (nvram_match ("wl0_mode", "sta")
439              || nvram_match ("wl0_mode", "wet")
440              || nvram_match ("wl0_mode", "apsta")
441              || nvram_match ("wl0_mode", "apstawet"))
442            {
443              //fix for client mode
444              cprintf ("ifconfig wl up\n");
445              eval ("/sbin/ifconfig", get_wdev (), "up");
446            }
447
448#ifndef HAVE_MADWIFI
449#ifdef HAVE_RADIOOFF
450          if (nvram_match ("radiooff_button", "1")
451              && nvram_match ("radiooff_boot_off", "1"))
452            {
453              eval ("wl", "-i", get_wl_instance_name (0), "radio", "off");
454            }
455          else
456#endif
457            start_service ("nas");
458#ifdef HAVE_MSSID
459          start_service ("guest_nas");
460#endif
461#endif
462
463          start_service ("radio_timer");
464#ifdef HAVE_VLANTAGGING
465          start_service ("vlantagging");
466          start_service ("bridgesif");
467#endif
468
469
470          cprintf ("create rc file\n");
471#ifdef HAVE_REGISTER
472          if (isregistered ())
473#endif
474            {
475              start_service ("create_rc_startup");
476              chmod ("/tmp/.rc_startup", 0700);
477              system ("/tmp/.rc_startup");
478              system ("/etc/init.d/rcS");       // start openwrt startup script (siPath impl)
479              cprintf ("start modules\n");
480              start_service ("modules");
481#ifdef HAVE_MILKFISH
482              start_service ("milkfish_boot");
483#endif
484              if (nvram_invmatch ("rc_custom", ""))     //create custom script
485                {
486                  nvram2file ("rc_custom", "/tmp/custom.sh");
487                  chmod ("/tmp/custom.sh", 0700);
488                }
489            }
490
491#ifdef HAVE_CHILLI
492          start_service ("chilli");
493#endif
494#ifdef HAVE_WIFIDOG
495          start_service ("wifidog");
496#endif
497          cprintf ("start syslog\n");
498#ifndef HAVE_WRK54G
499          startstop ("syslog");
500#endif
501#ifdef HAVE_RSTP
502//just experimental for playing
503          eval ("brctl", "stp", "br0", "off");
504          eval ("rstpd");
505          eval ("rstpctl", "rstp", "br0", "on");
506#endif
507
508          system ("/etc/postinit");
509
510          led_control (LED_DIAG, LED_OFF);
511          lcdmessage ("System Ready");
512          /* Fall through */
513        case TIMER:
514          cprintf ("TIMER\n");
515          do_timer ();
516          /* Fall through */
517        case IDLE:
518          cprintf ("IDLE\n");
519          state = IDLE;
520          /* Wait for user input or state change */
521          while (signalled == -1)
522            {
523              if (!noconsole && (!shell_pid || kill (shell_pid, 0) != 0))
524                shell_pid = ddrun_shell (0, 1);
525              else
526                sigsuspend (&sigset);
527
528            }
529          state = signalled;
530          signalled = -1;
531          break;
532#ifdef HAVE_X86
533        case REBOOT:
534          lcdmessage ("System Reboots!");
535          system ("reboot");
536          break;
537#endif
538        default:
539          cprintf ("UNKNOWN\n");
540          return 0;
541        }
542
543    }
544
545}
546
547int
548get_wanface (int argc, char **argv)
549{
550  fprintf (stdout, "%s", get_wan_face ());
551  return 0;
552}
553
554struct MAIN
555{
556  char *callname;
557  char *execname;
558  int (*exec) (int argc, char **argv);
559};
560
561static struct MAIN maincalls[] = {
562  {"init", NULL, &main_loop},
563  {"ip-up", "ipup", NULL},
564  {"ip-down", "ipdown", NULL},
565  {"ipdown", "disconnected_pppoe", NULL},
566  {"udhcpc", "udhcpc", NULL},
567#ifdef HAVE_PPTPD
568  {"poptop", NULL, &pptpd_main},
569#endif
570  {"redial", NULL, &redial_main},
571#ifndef HAVE_RB500
572  {"resetbutton", NULL, &resetbutton_main},
573#endif
574  {"wland", "wland", NULL},
575  {"hb_connect", "hb_connect", NULL},
576  {"hb_disconnect", "hb_disconnect", NULL},
577  {"gpio", "gpio", NULL},
578  {"beep", "beep", NULL},
579  {"listen", NULL, &listen_main},
580  {"check_ps", NULL, &check_ps_main},
581  {"ddns_success", "ddns_success", NULL},
582  {"process_monitor", NULL, &process_monitor_main},
583  {"radio_timer", NULL, &radio_timer_main},
584  {"ttraf", NULL, &ttraff_main},
585#ifdef HAVE_WIVIZ
586  {"run_wiviz", NULL, &run_wiviz_main},
587  {"autokill_wiviz", NULL, &autokill_wiviz_main},
588#endif
589  {"site_survey", "site_survey", NULL},
590#ifdef HAVE_WOL
591  {"wol", NULL, &wol_main},
592#endif
593  {"event", NULL, &event_main},
594  {"switch", "switch", NULL},
595//#ifdef HAVE_MICRO
596//  {"brctl", "brctl", NULL},
597//#endif
598  {"getbridgeprio", "getbridgeprio", NULL},
599  {"setuserpasswd", "setuserpasswd", NULL},
600  {"getbridge", "getbridge", NULL},
601  {"watchdog", NULL, &watchdog_main},
602  {"nvram", NULL, &nvram_main},
603#ifdef HAVE_ROAMING
604  {"roaming_daemon", NULL, &roaming_daemon_main},
605  {"supplicant", "supplicant", NULL},
606#endif
607  {"get_wanface", NULL, &get_wanface},
608#ifndef HAVE_XSCALE
609  {"ledtool", NULL, &ledtool_main},
610#endif
611#ifdef HAVE_REGISTER
612  {"regshell", NULL, &reg_main}
613#endif
614};
615
616int
617main (int argc, char **argv)
618{
619  char *base = strrchr (argv[0], '/');
620
621  base = base ? base + 1 : argv[0];
622  int i;
623  for (i = 0; i < sizeof (maincalls) / sizeof (struct MAIN); i++)
624    {
625      if (strstr (base, maincalls[i].callname))
626        {
627          if (maincalls[i].execname)
628            return start_main (maincalls[i].execname, argc, argv);
629          if (maincalls[i].exec)
630            return maincalls[i].exec (argc, argv);
631        }
632    }
633
634
635
636  if (strstr (base, "startservice"))
637    {
638      if (argc < 2)
639        {
640          puts ("try to be professional\n");
641          return 0;
642        }
643      return start_service (argv[1]);
644    }
645  if (strstr (base, "stopservice"))
646    {
647      if (argc < 2)
648        {
649          puts ("try to be professional\n");
650          return 0;
651        }
652      return stop_service (argv[1]);
653    }
654
655#ifndef HAVE_RB500
656#ifndef HAVE_X86
657  /* erase [device] */
658  if (strstr (base, "erase"))
659    {
660      int brand = getRouterBrand ();
661      if (brand == ROUTER_MOTOROLA || brand == ROUTER_MOTOROLA_V1 || brand == ROUTER_MOTOROLA_WE800G || brand == ROUTER_RT210W || brand == ROUTER_BUFFALO_WZRRSG54)     //these routers have problem erasing nvram, so we only software restore defaults
662        {
663          if (argv[1] && strcmp (argv[1], "nvram"))
664            {
665              fprintf (stderr,
666                       "Sorry, erasing nvram will get this router unuseable\n");
667              return 0;
668            }
669        }
670      else
671        {
672          if (argv[1])
673            return mtd_erase (argv[1]);
674          else
675            {
676              fprintf (stderr, "usage: erase [device]\n");
677              return EINVAL;
678            }
679        }
680      return 0;
681    }
682
683  /* write [path] [device] */
684  if (strstr (base, "write"))
685    {
686      if (argc >= 3)
687        return mtd_write (argv[1], argv[2]);
688      else
689        {
690          fprintf (stderr, "usage: write [path] [device]\n");
691          return EINVAL;
692        }
693    }
694#else
695  if (strstr (base, "erase"))
696    {
697      if (argv[1] && strcmp (argv[1], "nvram"))
698        {
699          fprintf (stderr, "Erasing configuration data...\n");
700          eval ("mount", "/usr/local", "-o", "remount,rw");
701          eval ("rm", "-f", "/tmp/nvram/*");    // delete nvram database
702          eval ("rm", "-f", "/tmp/nvram/.lock");        // delete nvram database
703          eval ("rm", "-f", "/etc/nvram/*");    // delete nvram database
704          eval ("mount", "/usr/local", "-o", "remount,ro");
705        }
706      return 0;
707    }
708#endif
709#endif
710  /* hotplug [event] */
711  if (strstr (base, "hotplug"))
712    {
713      if (argc >= 2)
714        {
715          fprintf (stderr, "hotplug %s\n", argv[1]);
716          if (!strcmp (argv[1], "net"))
717            return start_service ("hotplug_net");
718#ifdef HAVE_USBHOTPLUG
719          if (!strcmp (argv[1], "usb"))
720            return start_service ("hotplug_usb");
721#endif
722#ifdef HAVE_XSCALE
723          if (!strcmp (argv[1], "firmware"))
724            return eval ("/etc/upload", argv[1]);
725#endif
726        }
727      else
728        {
729          fprintf (stderr, "usage: hotplug [event]\n");
730          return EINVAL;
731        }
732      return 0;
733    }
734  //////////////////////////////////////////////////////
735  //
736  if (strstr (base, "filtersync"))
737    return start_service ("filtersync");
738  /* filter [add|del] number */
739  if (strstr (base, "filter"))
740    {
741      if (argv[1] && argv[2])
742        {
743          int num = 0;
744          if ((num = atoi (argv[2])) > 0)
745            {
746              if (strcmp (argv[1], "add") == 0)
747                return start_servicei ("filter_add", num);
748              else if (strcmp (argv[1], "del") == 0)
749                return start_servicei ("filter_del", num);
750            }
751        }
752      else
753        {
754          fprintf (stderr, "usage: filter [add|del] number\n");
755          return EINVAL;
756        }
757      return 0;
758    }
759
760  if (strstr (base, "restart_dns"))
761    {
762      stop_service ("dnsmasq");
763      stop_service ("udhcpd");
764      start_service ("udhcpd");
765      start_service ("dnsmasq");
766      return 0;
767    }
768  if (strstr (base, "setpasswd"))
769    {
770      start_service ("mkfiles");
771      return 0;
772    }
773  /* rc [stop|start|restart ] */
774  else if (strstr (base, "rc"))
775    {
776      if (argv[1])
777        {
778          if (strncmp (argv[1], "start", 5) == 0)
779            return kill (1, SIGUSR2);
780          else if (strncmp (argv[1], "stop", 4) == 0)
781            return kill (1, SIGINT);
782          else if (strncmp (argv[1], "restart", 7) == 0)
783            return kill (1, SIGHUP);
784        }
785      else
786        {
787          fprintf (stderr, "usage: rc [start|stop|restart]\n");
788          return EINVAL;
789        }
790    }
791  return 1;
792}
Note: See TracBrowser for help on using the repository browser.