Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/runit/runsvdir.c

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

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 73  struct globals { Line 73  struct globals {
73    
74  static void fatal2_cannot(const char *m1, const char *m2)  static void fatal2_cannot(const char *m1, const char *m2)
75  {  {
76   bb_perror_msg_and_die("%s: fatal: cannot %s%s", svdir, m1, m2);   bb_perror_msg_and_die("%s: fatal: can't %s%s", svdir, m1, m2);
77   /* was exiting 100 */   /* was exiting 100 */
78  }  }
79  static void warn3x(const char *m1, const char *m2, const char *m3)  static void warn3x(const char *m1, const char *m2, const char *m3)
# Line 82  static void warn3x(const char *m1, const Line 82  static void warn3x(const char *m1, const
82  }  }
83  static void warn2_cannot(const char *m1, const char *m2)  static void warn2_cannot(const char *m1, const char *m2)
84  {  {
85   warn3x("cannot ", m1, m2);   warn3x("can't ", m1, m2);
86  }  }
87  #if ENABLE_FEATURE_RUNSVDIR_LOG  #if ENABLE_FEATURE_RUNSVDIR_LOG
88  static void warnx(const char *m1)  static void warnx(const char *m1)
# Line 119  static NOINLINE pid_t runsv(const char * Line 119  static NOINLINE pid_t runsv(const char *
119   | (1 << SIGTERM)   | (1 << SIGTERM)
120   , SIG_DFL);   , SIG_DFL);
121  #endif  #endif
122   execlp("runsv", "runsv", name, NULL);   execlp("runsv", "runsv", name, (char *) NULL);
123   fatal2_cannot("start runsv ", name);   fatal2_cannot("start runsv ", name);
124   }   }
125   return pid;   return pid;
# Line 129  static NOINLINE pid_t runsv(const char * Line 129  static NOINLINE pid_t runsv(const char *
129  static NOINLINE int do_rescan(void)  static NOINLINE int do_rescan(void)
130  {  {
131   DIR *dir;   DIR *dir;
132   direntry *d;   struct dirent *d;
133   int i;   int i;
134   struct stat s;   struct stat s;
135   int need_rescan = 0;   int need_rescan = 0;
# Line 256  int runsvdir_main(int argc UNUSED_PARAM, Line 256  int runsvdir_main(int argc UNUSED_PARAM,
256   if (rploglen < 7) {   if (rploglen < 7) {
257   warnx("log must have at least seven characters");   warnx("log must have at least seven characters");
258   } else if (piped_pair(logpipe)) {   } else if (piped_pair(logpipe)) {
259   warnx("cannot create pipe for log");   warnx("can't create pipe for log");
260   } else {   } else {
261   close_on_exec_on(logpipe.rd);   close_on_exec_on(logpipe.rd);
262   close_on_exec_on(logpipe.wr);   close_on_exec_on(logpipe.wr);
263   ndelay_on(logpipe.rd);   ndelay_on(logpipe.rd);
264   ndelay_on(logpipe.wr);   ndelay_on(logpipe.wr);
265   if (dup2(logpipe.wr, 2) == -1) {   if (dup2(logpipe.wr, 2) == -1) {
266   warnx("cannot set filedescriptor for log");   warnx("can't set filedescriptor for log");
267   } else {   } else {
268   pfd[0].fd = logpipe.rd;   pfd[0].fd = logpipe.rd;
269   pfd[0].events = POLLIN;   pfd[0].events = POLLIN;
# Line 370  int runsvdir_main(int argc UNUSED_PARAM, Line 370  int runsvdir_main(int argc UNUSED_PARAM,
370   opt_s_argv[1] = utoa(bb_got_signal);   opt_s_argv[1] = utoa(bb_got_signal);
371   pid = spawn(opt_s_argv);   pid = spawn(opt_s_argv);
372   if (pid > 0) {   if (pid > 0) {
373   /* Remebering to wait for _any_ children,   /* Remembering to wait for _any_ children,
374   * not just pid */   * not just pid */
375   while (wait(NULL) != pid)   while (wait(NULL) != pid)
376   continue;   continue;
377   }   }
378   }   }
379    
380   switch (bb_got_signal) {   if (bb_got_signal == SIGHUP) {
  case SIGHUP:  
381   for (i = 0; i < svnum; i++)   for (i = 0; i < svnum; i++)
382   if (sv[i].pid)   if (sv[i].pid)
383   kill(sv[i].pid, SIGTERM);   kill(sv[i].pid, SIGTERM);
  /* Fall through */  
  default: /* SIGTERM (or SIGUSRn if we are init) */  
  /* Exit unless we are init */  
  if (getpid() == 1)  
  break;  
  return (SIGHUP == bb_got_signal) ? 111 : EXIT_SUCCESS;  
384   }   }
385     /* SIGHUP or SIGTERM (or SIGUSRn if we are init) */
386     /* Exit unless we are init */
387     if (getpid() != 1)
388     return (SIGHUP == bb_got_signal) ? 111 : EXIT_SUCCESS;
389    
390     /* init continues to monitor services forever */
391   bb_got_signal = 0;   bb_got_signal = 0;
392   } /* for (;;) */   } /* for (;;) */
393  }  }

Legend:
Removed from v.983  
changed lines
  Added in v.984