Subject: bin/3280: ypserv creats pid file of wrong contents; it records pid of parent
To: None <gnats-bugs@gnats.netbsd.org>
From: None <enami@ba2.so-net.or.jp>
List: netbsd-bugs
Date: 03/03/1997 22:42:53
>Number: 3280
>Category: bin
>Synopsis: ypserv creats pid file of wrong contents; it records pid of parent
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Mar 3 06:20:01 1997
>Last-Modified:
>Originator: enami tsugutomo
>Organization:
An individual
>Release: NetBSD-current 1997 Mar01
>Environment:
System: NetBSD pavlov.enami.ba2.so-net.or.jp 1.2C NetBSD 1.2C (PAVLOV) #164: Sat Feb 8 01:00:12 JST 1997 enami@pavlov.enami.ba2.so-net.or.jp:/b/netbsd/kernel/compile/PAVLOV i386
>Description:
Ypserv creats pid file of wrong contents; it records pid of
parent process instead of daemon process. It writes pid file
before calling daemon().
>How-To-Repeat:
Invoke ypserv with daemon mode and see the contents of pid
file, /var/run/ypserv.pid. It hold the number probably one
less than you intended.
>Fix:
Write pid file after calling daemon(). Note that this patch
also includes indentation fix of line `openlog("ypserv",
LOG_PID, LOG_DAEMON);'.
Index: ypserv.c
===================================================================
RCS file: /a/cvsroot/NetBSD/src/usr.sbin/ypserv/ypserv/ypserv.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 ypserv.c
*** ypserv.c 1996/11/16 16:55:30 1.1.1.1
--- ypserv.c 1997/03/03 13:36:51
***************
*** 279,284 ****
--- 279,290 ----
if (xflag)
exit(1);
+ #ifndef RPC_SVC_FG
+ if (daemon(0, 0))
+ err(1, "can't detatch");
+ openlog("ypserv", LOG_PID, LOG_DAEMON);
+ #endif
+
{
FILE *pidfile = fopen(YPSERV_PID_PATH, "w");
***************
*** 289,299 ****
err(1, "can't write PID file");
}
- #ifndef RPC_SVC_FG
- if (daemon(0, 0))
- err(1, "can't detatch");
- openlog("ypserv", LOG_PID, LOG_DAEMON);
- #endif
sock = RPC_ANYSOCK;
(void) pmap_unset(YPPROG, YPVERS);
--- 295,300 ----
>Audit-Trail:
>Unformatted: