From owner-freebsd-bugs Sun Jun 15 07:10:04 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id HAA10946 for bugs-outgoing; Sun, 15 Jun 1997 07:10:04 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.5/8.8.5) id HAA10940; Sun, 15 Jun 1997 07:10:01 -0700 (PDT) Resent-Date: Sun, 15 Jun 1997 07:10:01 -0700 (PDT) Resent-Message-Id: <199706151410.HAA10940@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, sanewo@ba2.so-net.or.jp Received: from sanewo.ba2.so-net.or.jp (pppba24.pppp.ap.so-net.or.jp [210.132.186.36]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id HAA10885 for ; Sun, 15 Jun 1997 07:08:18 -0700 (PDT) Received: (from sanewo@localhost) by sanewo.ba2.so-net.or.jp (8.8.5/8.7.3) id SAA07766; Sun, 15 Jun 1997 18:04:22 +0900 (JST) Message-Id: <199706150904.SAA07766@sanewo.ba2.so-net.or.jp> Date: Sun, 15 Jun 1997 18:04:22 +0900 (JST) From: sanewo@ba2.so-net.or.jp Reply-To: sanewo@ba2.so-net.or.jp To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/3874: ppp pidfile does not match actual pid of ppp Sender: owner-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >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: