diff options
author | brian <brian@FreeBSD.org> | 1997-03-13 21:22:09 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1997-03-13 21:22:09 +0000 |
commit | d14412c59dead9d8b503bd8c6cbbde710b76e7cd (patch) | |
tree | 5382fdc918a7ddd746a4479e346c565cf86d909e | |
parent | db004d74c87a0b50369d35291f1901c6f4746444 (diff) | |
download | FreeBSD-src-d14412c59dead9d8b503bd8c6cbbde710b76e7cd.zip FreeBSD-src-d14412c59dead9d8b503bd8c6cbbde710b76e7cd.tar.gz |
Closes pr 2711
Fix -background option. Parent returns after the line is established
(or not established).
Definitely a candidate for 2.2
-rw-r--r-- | usr.sbin/ppp/lcp.c | 11 | ||||
-rw-r--r-- | usr.sbin/ppp/main.c | 35 |
2 files changed, 35 insertions, 11 deletions
diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index 428fa11..13b9f30 100644 --- a/usr.sbin/ppp/lcp.c +++ b/usr.sbin/ppp/lcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id$ + * $Id: lcp.c,v 1.12 1997/02/22 16:10:23 peter Exp $ * * TODO: * o Validate magic number received from peer. @@ -123,6 +123,15 @@ int new; IpcpOpen(); CcpUp(); CcpOpen(); + if (mode & MODE_BACKGROUND && BGFiledes[1] != -1) { + char c = EX_NORMAL; + if (write(BGFiledes[1],&c,1) == 1) + LogPrintf(LOG_PHASE_BIT,"Parent notified of success.\n"); + else + LogPrintf(LOG_PHASE_BIT,"Failed to notify parent of success.\n"); + close(BGFiledes[1]); + BGFiledes[1] = -1; + } break; case PHASE_DEAD: if (mode & MODE_DIRECT) diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 1634273..46a0f7d 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.38 1997/03/13 12:45:30 brian Exp $ + * $Id: main.c,v 1.39 1997/03/13 14:53:55 brian Exp $ * * TODO: * o Add commands for traffic summary, version display, etc. @@ -159,13 +159,19 @@ int excode; OsLinkdown(); OsCloseLink(1); sleep(1); - if (mode & MODE_AUTO) { - DeleteIfRoutes(1); - } if (mode & (MODE_AUTO | MODE_BACKGROUND)) { + DeleteIfRoutes(1); unlink(pid_filename); } OsInterfaceDown(1); + if (mode & MODE_BACKGROUND && BGFiledes[1] != -1) { + char c = EX_ERRDEAD; + if (write(BGFiledes[1],&c,1) == 1) + LogPrintf(LOG_PHASE_BIT,"Parent notified of failure.\n"); + else + LogPrintf(LOG_PHASE_BIT,"Failed to notify parent of failure.\n"); + close(BGFiledes[1]); + } LogPrintf(LOG_PHASE_BIT, "PPP Terminated.\n"); LogClose(); if (server >= 0) { @@ -440,12 +446,18 @@ char **argv; if (mode & MODE_BACKGROUND) { /* Wait for our child to close its pipe before we exit. */ BGPid = bgpid; - read (BGFiledes[0], &c, 1); - if (c == EX_NORMAL) - LogPrintf (LOG_CHAT, "PPP enabled.\n"); + close (BGFiledes[1]); + if (read(BGFiledes[0], &c, 1) != 1) + LogPrintf (LOG_PHASE_BIT, "Parent: Child exit, no status.\n"); + else if (c == EX_NORMAL) + LogPrintf (LOG_PHASE_BIT, "Parent: PPP enabled.\n"); + else + LogPrintf (LOG_PHASE_BIT, "Parent: Child failed %d.\n",(int)c); + close (BGFiledes[0]); } exit(c); - } + } else if (mode & MODE_BACKGROUND) + close(BGFiledes[0]); snprintf(pid_filename, sizeof (pid_filename), "%s/ppp.tun%d.pid", _PATH_VARRUN, tunno); @@ -705,7 +717,7 @@ DoLoop() pgroup = getpgrp(); - if (mode & MODE_DIRECT) { + if (mode & (MODE_DIRECT|MODE_BACKGROUND)) { modem = OpenModem(mode); LogPrintf(LOG_PHASE_BIT, "Packet mode enabled\n"); fflush(stderr); @@ -720,7 +732,10 @@ DoLoop() timeout.tv_sec = 0; timeout.tv_usec = 0; - dial_up = FALSE; /* XXXX */ + if (mode & MODE_BACKGROUND) + dial_up = TRUE; /* Bring the line up */ + else + dial_up = FALSE; /* XXXX */ tries = 0; for (;;) { nfds = 0; |