Can't load daemon at boot

andris at multicom.lv andris at multicom.lv
Tue Sep 9 08:42:57 PDT 2003


Hi!

I have a programm with code like this (this is example, the real code is
at
http://fresh.t-systems-sfr.com/linux/src/.warix/logserial-0.4.2.tar.gz.html):

####################
void shutdown(int sig) {
   switch (sig) {
       default:
           fprintf(stderr, "Got signal %d. Exit\n", sig);
           break;
   }
   exit(EXIT_SUCCESS);
}

int main(void) {
   chproc = fork();
   if (chproc == -1) {
       perror("Unable to fork");
       exit(EXIT_FAILURE);
   }
   if (chproc != 0) {
       fprintf(stderr, "Starting daemon...\n");
       exit(EXIT_SUCCESS);
   }

   signal(SIGHUP, &shutdown);
   signal(SIGINT, &shutdown);
   signal(SIGQUIT, &shutdown);
   signal(SIGTERM, &shutdown);
   signal(SIGABRT, &shutdown);

   while (1) {
       sleep(1);
   }

   return 0;
}
####################

When I load a.out from terminal it run fine.
I want this programm run at every boot so I place this command in
/etc/rc.local or /usr/local/etc/rc.d/prog.sh.
After boot it not run and in logs I see message "Got signal 1. Exit".

Any ideas?

Andris




More information about the freebsd-stable mailing list