Subject: port-i386/2825: syslogd -d writes pid file and confuses newsyslog
To: None <gnats-bugs@gnats.netbsd.org>
From: Heiko W.Rupp <hwr@pilhuhn.de>
List: netbsd-bugs
Date: 10/09/1996 10:40:49
>Number:         2825
>Category:       port-i386
>Synopsis:       syslogd -d writes pid file and thus confuses newsyslog
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct  9 11:35:03 1996
>Last-Modified:
>Originator:     Heiko W.Rupp
>Organization:
Heiko W.Rupp        Gerwigstr.5        D-76131  Karlsruhe    +49 721 9661524
>Release:        1.1
>Environment:
	
System: NetBSD snert.pilhuhn.de 1.1 NetBSD 1.1 (SNERT) #64: Fri Oct 4 20:43:25 GMT+0200 1996 hwr@snert.pilhuhn.de:/4pil/hwr/sys/arch/i386/compile/SNERT i386


>Description:
In order to debug syslogging, one can run ``syslogd -d'' which takes
over the log socket and displays all syslog activity to the user.
After an interrupt, this syslogd terminates and the "normal one" (that
that is started at system boot) takes over the logging.

>From now on you will get mails from cron with the following contents:

/usr/bin/newsyslog: warning - could not restart syslogd: No such process

This is because ``syslogd -d'' which isn't a real daemon writes its
pid to /var/run/syslog.pid


>How-To-Repeat:

<reboot>

snert# syslogd -d
......

^C

snert# cat syslog.pid
27140
snert# ps auxw|grep sysl
root        70  0.0  1.3    76  268 ??  Is   Fri09PM    0:14.99 syslogd 


>Fix:

Something like:

*** syslogd.c,1	Sat Oct 14 07:07:15 1995
--- syslogd.c	Wed Oct  9 10:39:47 1996
***************
*** 290,299 ****
  	}
  
  	/* tuck my process id away */
! 	fp = fopen(PidFile, "w");
! 	if (fp != NULL) {
! 		fprintf(fp, "%d\n", getpid());
! 		(void) fclose(fp);
  	}
  
  	dprintf("off & running....\n");
--- 290,301 ----
  	}
  
  	/* tuck my process id away */
! 	if (!Debug)
! 		fp = fopen(PidFile, "w");
! 		if (fp != NULL) {
! 			fprintf(fp, "%d\n", getpid());
! 			(void) fclose(fp);
! 		}
  	}
  
  	dprintf("off & running....\n");
>Audit-Trail:
>Unformatted: