[BusyBox] syslogd startup race

Vadim Berkgaut berk at rc.ru
Tue Jun 12 06:38:08 UTC 2001


When busybox syslogd starts up and daemon()s, the parent
process immediately exits and returns control to the calling
script. The child proceeds with syslogd initialization.

This leads to race condition if, for instance, klogd is
next to be started. Depending on who wins the race, syslogd
can record any number of klogd messages.

Maybe it is worthwhile to add an advice to sleep for a few seconds
after starting syslogd? It is done like this in Berkeley sysklogd,
but inside the code:

// Berkeley sysklogd v.1.3, syslogd.c
        if (fork())
        {
                /* We try to wait the end of initialization */
                sleep(10);
                exit(0);
        }

Another buglet is with -C option to syslogd. When started this way,
syslogd exited with the following message:

   syslog: semop[SMwup]: Try again

It seems that syslogd tries to up a semaphore which is already up.
It started smoothly with the following patch:

--- syslogd.c.orig      Tue Jun 12 15:36:10 2001
+++ syslogd.c   Tue Jun 12 15:37:30 2001
@@ -157,8 +157,6 @@
                    perror_msg_and_die("semget");
                }else
                        perror_msg_and_die("semget");
-           } else {
-                   sem_up(s_semid);
            }
        }else{
                printf("Buffer already allocated just grab the semaphore?");

Vadim







More information about the busybox mailing list