summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-01-17 19:28:06 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-01-17 19:28:06 +0000
commit02eeabc4c9a749a24baf25cbe002ed45f42bbca7 (patch)
tree8eb7fab92c395b208d6ab3cfd12d7474acda9c38
parentac4143def573a4193f2321bebed9b4fb2e0f2ac7 (diff)
move handler into main loop
-rw-r--r--sbin/slattach/slattach.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/sbin/slattach/slattach.c b/sbin/slattach/slattach.c
index 5d578475999..555f8f90df6 100644
--- a/sbin/slattach/slattach.c
+++ b/sbin/slattach/slattach.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: slattach.c,v 1.7 2001/01/15 20:03:32 deraadt Exp $ */
+/* $OpenBSD: slattach.c,v 1.8 2001/01/17 19:28:05 deraadt Exp $ */
/* $NetBSD: slattach.c,v 1.17 1996/05/19 21:57:39 jonathan Exp $ */
/*
@@ -47,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)slattach.c 8.2 (Berkeley) 1/7/94";
#else
-static char rcsid[] = "$OpenBSD: slattach.c,v 1.7 2001/01/15 20:03:32 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: slattach.c,v 1.8 2001/01/17 19:28:05 deraadt Exp $";
#endif
#endif /* not lint */
@@ -87,6 +87,8 @@ int ttydisc __P((char *));
void handler __P((int));
+sig_atomic_t dying;
+
int
main(argc, argv)
int argc;
@@ -175,24 +177,27 @@ main(argc, argv)
}
sigemptyset(&sigset);
- for (;;)
+ for (;;) {
sigsuspend(&sigset);
+ if (dying) {
+ /* delete the pid file. */
+ if (pidfilename[0] != 0) {
+ if (unlink(pidfilename) < 0 && errno != ENOENT)
+ syslog(LOG_WARNING,
+ "unable to delete pid file: %m");
+ }
+
+ /* terminate gracefully */
+ exit(0);
+ }
+ }
}
void
handler(useless)
int useless;
{
-
- /* delete the pid file. */
- if (pidfilename[0] != 0) {
- if (unlink(pidfilename) < 0 && errno != ENOENT)
- syslog(LOG_WARNING, "unable to delete pid file: %m");
- pidfilename[0] = 0;
- }
-
- /* terminate gracefully */
- _exit(0);
+ dying = 1;
}