[BusyBox] Hanging syslogd processes

Pavel Roskin proski at gnu.org
Mon Aug 21 18:52:49 UTC 2000


Hello!

I have noticed that a recent patch to syslogd.c pretends to solve the
problem with processes that don't exit (I'm not saying that it's
incorrect).

In fact, that patch has no effect on the system I'm working with (embedded
Linux PPC). There are still hanging processes. They are waiting in read()
called from serveConnection() - I can prove it.

The patch below makes syslogd write the last executed line number to the
command line displayed by ps. The result shows that there are two
processes that have executed the line before read(), but not the line
after read():

    1 root     wheel    S init
    2 root     wheel    S [kflushd]
    3 root     wheel    S [kupdate]
    4 root     wheel    S [kpiod]
    5 root     wheel    S [kswapd]
    6 root     wheel    S [rpciod]
   36 root     wheel    S klogd   -m 0
   37 root     wheel    S syslogd -m 0
   38 root     wheel    S crond
   48 root     wheel    S /bin/sinetd 21 /bin/in.ftpd
   49 root     wheel    S /bin/sinetd 23 /bin/in.telnetd
   50 root     wheel    S MARK-222-  0
   51 root     wheel    S -bash
   52 root     wheel    S MARK-222-  0
   58 root     wheel    R ps

The patch (it's long due to someone's bad habit of combining declarations 
and assignments):

===========================
diff -u -r1.38 syslogd.c
--- syslogd.c	2000/08/20 06:11:32	1.38
+++ syslogd.c	2000/08/21 18:45:20
@@ -205,18 +205,30 @@
 }
 
 #define BUFSIZE 1023
+char *argv0;
+#define MARK sprintf (argv0, "MARK-%d-", __LINE__);
 static int serveConnection (int conn)
 {
 	char   buf[ BUFSIZE + 1 ];
 	int    n_read;
 
-	while ((n_read = read (conn, buf, BUFSIZE )) > 0) {
-
-		int           pri = (LOG_USER | LOG_NOTICE);
+	while (1) {
+		int           pri;
 		char          line[ BUFSIZE + 1 ];
 		unsigned char c;
+
+		char *p, *q;
+
+MARK;
+		n_read = read (conn, buf, BUFSIZE );
+MARK;
+		if (n_read <= 0)
+			break;
+
+		pri = (LOG_USER | LOG_NOTICE);
 
-		char *p = buf, *q = line;
+		p = buf;
+		q = line;
 
 		buf[ n_read - 1 ] = '\0';
 
@@ -488,6 +500,7 @@
 	char *p;
 	char **argv1 = argv;
 
+	argv0 = *argv;
 	while (--argc > 0 && **(++argv1) == '-') {
 		stopDoingThat = FALSE;
 		while (stopDoingThat == FALSE && *(++(*argv1))) {
===========================

I have no idea how to solve the problem for real.

Regards,
Pavel Roskin






More information about the busybox mailing list