Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Jun 1997 18:04:22 +0900 (JST)
From:      sanewo@ba2.so-net.or.jp
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/3874: ppp pidfile does not match actual pid of ppp
Message-ID:  <199706150904.SAA07766@sanewo.ba2.so-net.or.jp>
Resent-Message-ID: <199706151410.HAA10940@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         3874
>Category:       bin
>Synopsis:       ppp pidfile (/var/run/tunN.pid) does not match actual pid of ppp
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jun 15 07:10:00 PDT 1997
>Last-Modified:
>Originator:     Takanori Saneto
>Organization:
an individual
>Release:        FreeBSD 3.0-CURRENT i386
>Environment:

	FreeBSD 3.0-CURRENT as of Jun 12.

>Description:

	In auto or background mode, ppp's pid file (/var/run/tunN.pid)
	contains incorrect pid in it.

	Here is the scenario:
	Parent forks child and exits.
	Child creates pid file and then calls daemon(), which forks grandchild and then exits.
	Grandchild, which perfoms rest of the job, has different pid than that in pid file.

>How-To-Repeat:

	Invoke ppp in auto or background mode and see contents of /var/run/tunN.pid.

>Fix:
	
	Calling daemon() before creating pid file seems to fix this problem.
	I don't know if there are any side-effects by doing this.

Index: main.c
===================================================================
RCS file: /sd0/FreeBSD/cvs/src/usr.sbin/ppp/main.c,v
retrieving revision 1.61
diff -u -r1.61 main.c
--- main.c	1997-06-11 12:57:48+09	1.61
+++ main.c	1997-06-15 17:58:12+09
@@ -485,6 +485,18 @@
           close(BGFiledes[0]);
     }
 
+    VarTerm = 0;   /* We know it's currently stdin */
+
+#ifdef DOTTYINIT
+    if (mode & (MODE_DIRECT|MODE_DEDICATED)) { /* } */
+#else
+    if (mode & MODE_DIRECT) {
+#endif
+      chdir("/");  /* Be consistent with daemon() */
+      TtyInit();
+    } else
+      daemon(0,0);
+
     snprintf(pid_filename, sizeof (pid_filename), "%stun%d.pid",
              _PATH_VARRUN, tunno);
     (void)unlink(pid_filename);
@@ -509,18 +521,6 @@
 
     if (server >= 0)
 	LogPrintf(LogPHASE, "Listening at %d.\n", port);
-
-    VarTerm = 0;   /* We know it's currently stdin */
-
-#ifdef DOTTYINIT
-    if (mode & (MODE_DIRECT|MODE_DEDICATED)) { /* } */
-#else
-    if (mode & MODE_DIRECT) {
-#endif
-      chdir("/");  /* Be consistent with daemon() */
-      TtyInit();
-    } else
-      daemon(0,0);
   } else {
     TtyInit();
     TtyCommandMode(1);
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199706150904.SAA07766>