summaryrefslogtreecommitdiffstats
path: root/sbin/startslip/startslip.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1995-09-15 20:34:55 +0000
committerache <ache@FreeBSD.org>1995-09-15 20:34:55 +0000
commitfa6033fe95fe048e7e3e0249f5b4108cbe24b0fc (patch)
tree782e0700aa5649523d3669635971a505313a6c28 /sbin/startslip/startslip.c
parent9299d1d254cee8b73b2802dfcbcf48cc7ff86aeb (diff)
downloadFreeBSD-src-fa6033fe95fe048e7e3e0249f5b4108cbe24b0fc.zip
FreeBSD-src-fa6033fe95fe048e7e3e0249f5b4108cbe24b0fc.tar.gz
Close line before fork, or becomes close twice.
Debug output cleanup.
Diffstat (limited to 'sbin/startslip/startslip.c')
-rw-r--r--sbin/startslip/startslip.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/sbin/startslip/startslip.c b/sbin/startslip/startslip.c
index 82de891..4d3ac7b 100644
--- a/sbin/startslip/startslip.c
+++ b/sbin/startslip/startslip.c
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: startslip.c,v 1.10 1995/09/15 20:06:50 ache Exp $
*/
#ifndef lint
@@ -223,30 +223,8 @@ restart:
*/
down(3);
}
- if (diali > 0)
- dialerstring = dials[dialc++ % diali];
-
- /*
- * We may get a HUP below, when the parent (session leader/
- * controlling process) exits; ignore HUP until into new session.
- */
signal(SIGHUP, SIG_IGN);
hup = 0;
- if (fork() > 0) {
- if (first)
- printd("parent exit\n");
- exit(0);
- }
- if (setsid() < 0) {
- syslog(LOG_ERR, "setsid: %m");
- down(2);
- }
- pid = getpid();
- printd("restart: pid %ld: ", pid);
- if ((pfd = fopen(pidfile, "w")) != NULL) {
- fprintf(pfd, "%ld\n", pid);
- fclose(pfd);
- }
if (wfd) {
printd("fclose, ");
fclose(wfd);
@@ -264,11 +242,31 @@ restart:
fd = -1;
sleep(5);
}
+ if (terminate)
+ goto restart;
+ if (diali > 0)
+ dialerstring = dials[dialc++ % diali];
+
+ if (fork() > 0) {
+ if (first)
+ printd("parent exit\n");
+ exit(0);
+ }
+ if (setsid() < 0) {
+ syslog(LOG_ERR, "setsid: %m");
+ down(2);
+ }
+ pid = getpid();
+ printd("restart: pid %ld: ", pid);
+ if ((pfd = fopen(pidfile, "w")) != NULL) {
+ fprintf(pfd, "%ld\n", pid);
+ fclose(pfd);
+ }
if (tries > 1) {
syslog(LOG_INFO, "sleeping %d seconds (%d tries)",
- wait_time * (tries - 1), tries - 1);
+ wait_time * (tries - 1), tries);
sleep(wait_time * (tries - 1));
- if (hup || terminate)
+ if (terminate)
goto restart;
}
printd("open");
@@ -310,7 +308,7 @@ restart:
syslog(LOG_ERR, "tcsetpgrp failed: %m");
down(2);
}
- printd(", ioctl");
+ printd(", ioctl\n");
if (tcgetattr(fd, &t) < 0) {
syslog(LOG_ERR, "%s: tcgetattr: %m\n", devicename);
down(2);
@@ -345,10 +343,10 @@ restart:
}
setbuf(wfd, (char *)0);
if (dialerstring) {
- printd(", send dialstring: %s\\r", dialerstring);
+ printd("send dialstring: %s\\r", dialerstring);
fprintf(wfd, "%s\r", dialerstring);
} else {
- printd(", send \\r");
+ printd("send \\r");
putc('\r', wfd);
}
printd("\n");
OpenPOWER on IntegriCloud