diff options
author | brian <brian@FreeBSD.org> | 1997-05-10 03:39:57 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1997-05-10 03:39:57 +0000 |
commit | 625e8802da19871e465f595a01b0cc34493cb200 (patch) | |
tree | 10b9c5f12ab5ab1eb73b70d01f34abe7d3acab11 /usr.sbin/ppp/main.c | |
parent | ee523bb0cbc38ef1b0865690d30095b8d9453449 (diff) | |
download | FreeBSD-src-625e8802da19871e465f595a01b0cc34493cb200.zip FreeBSD-src-625e8802da19871e465f595a01b0cc34493cb200.tar.gz |
Add a ttyXX.if file in /var/run that points to
the tunX.pid file. Change the ppp.tunX.pid name
to tunX.pid
Requested by: Daniel O Callaghan <danny@panda.hilink.com.au>
Diffstat (limited to 'usr.sbin/ppp/main.c')
-rw-r--r-- | usr.sbin/ppp/main.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 755c449..967cca3 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: main.c,v 1.46 1997/05/04 02:39:03 ache Exp $ + * $Id: main.c,v 1.47 1997/05/10 01:22:15 brian Exp $ * * TODO: * o Add commands for traffic summary, version display, etc. @@ -76,7 +76,8 @@ int TermMode; static int server; static pid_t BGPid = 0; struct sockaddr_in ifsin; -char pid_filename[128]; +static char pid_filename[MAXPATHLEN]; +static char if_filename[MAXPATHLEN]; int tunno; static void @@ -170,6 +171,7 @@ int excode; if (mode & (MODE_AUTO | MODE_BACKGROUND)) { DeleteIfRoutes(1); unlink(pid_filename); + unlink(if_filename); } OsInterfaceDown(1); if (mode & MODE_BACKGROUND && BGFiledes[1] != -1) { @@ -430,8 +432,7 @@ char **argv; DupLog(); if (!(mode & MODE_DIRECT)) { - int fd; - char pid[32]; + FILE *lockfile; pid_t bgpid; bgpid = fork (); @@ -458,15 +459,24 @@ char **argv; } else if (mode & MODE_BACKGROUND) close(BGFiledes[0]); - snprintf(pid_filename, sizeof (pid_filename), "%s/ppp.tun%d.pid", + snprintf(pid_filename, sizeof (pid_filename), "%s/tun%d.pid", _PATH_VARRUN, tunno); unlink(pid_filename); - snprintf(pid, sizeof(pid), "%d\n", (int)getpid()); - if ((fd = open(pid_filename, O_RDWR|O_CREAT, 0666)) != -1) + if ((lockfile = fopen(pid_filename, "w")) != NULL) + { + fprintf(lockfile, "%d\n", (int)getpid()); + fclose(lockfile); + } + + snprintf(if_filename, sizeof if_filename, "%s%s.if", + _PATH_VARRUN, VarBaseDevice); + unlink(if_filename); + + if ((lockfile = fopen(if_filename, "w")) != NULL) { - write(fd, pid, strlen(pid)); - close(fd); + fprintf(lockfile, "tun%d\n", tunno); + fclose(lockfile); } } if (server >= 0) |