summaryrefslogtreecommitdiffstats
path: root/libexec/pppoed/pppoed.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2000-12-04 22:13:30 +0000
committerbrian <brian@FreeBSD.org>2000-12-04 22:13:30 +0000
commite01a4c0fd9aff88ae8d9b70d8f82aaf56c9c9116 (patch)
tree351721f21ff54cd90643ede8d8dff5df450804fc /libexec/pppoed/pppoed.c
parent8bd975051ebdbe73def349683309a3e8817a810c (diff)
downloadFreeBSD-src-e01a4c0fd9aff88ae8d9b70d8f82aaf56c9c9116.zip
FreeBSD-src-e01a4c0fd9aff88ae8d9b70d8f82aaf56c9c9116.tar.gz
Drop out of our main loop due to a signal rather than handling things in the
signal handler. Fix a spelling error. Subtley pointed out by: bde Make some stuff static
Diffstat (limited to 'libexec/pppoed/pppoed.c')
-rw-r--r--libexec/pppoed/pppoed.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/libexec/pppoed/pppoed.c b/libexec/pppoed/pppoed.c
index d1878f7..1e4d24b 100644
--- a/libexec/pppoed/pppoed.c
+++ b/libexec/pppoed/pppoed.c
@@ -63,6 +63,8 @@
#define DEFAULT_EXEC_PREFIX "exec /usr/sbin/ppp -direct "
+static int ReceivedSignal;
+
static int
usage(const char *prog)
{
@@ -71,24 +73,11 @@ usage(const char *prog)
return EX_USAGE;
}
-const char *pidfile;
-
static void
-Fairwell(int sig)
+Farewell(int sig)
{
- char buf[] = "Received signal XX, exiting";
-
- /* No stdio in a signal handler */
- buf[16] = '0' + ((sig / 10) % 10);
- buf[17] = '0' + (sig % 10);
-
- syslog(LOG_INFO, "%s", buf);
-
- if (pidfile)
- remove(pidfile);
-
- signal(sig, SIG_DFL);
- raise(sig);
+ ReceivedSignal = sig;
+ signal(sig, SIG_DFL); /* If something makes us block... */
}
static int
@@ -418,7 +407,7 @@ Spawn(const char *prog, const char *acname, const char *exec,
}
#ifndef NOKLDLOAD
-int
+static int
LoadModules(void)
{
const char *module[] = { "netgraph", "ng_socket", "ng_ether", "ng_pppoe" };
@@ -434,7 +423,7 @@ LoadModules(void)
}
#endif
-void
+static void
nglog(const char *fmt, ...)
{
char nfmt[256];
@@ -446,7 +435,7 @@ nglog(const char *fmt, ...)
va_end(ap);
}
-void
+static void
nglogx(const char *fmt, ...)
{
va_list ap;
@@ -464,6 +453,7 @@ main(int argc, char **argv)
const char *prog, *provider, *acname;
struct ngm_connect ngc;
int ch, cs, ds, ret, optF, optd, optn, sz, f;
+ const char *pidfile;
prog = strrchr(argv[0], '/');
prog = prog ? prog + 1 : argv[0];
@@ -584,12 +574,12 @@ main(int argc, char **argv)
if (!optF && optn)
NgSetErrLog(nglog, nglogx);
- signal(SIGHUP, Fairwell);
- signal(SIGINT, Fairwell);
- signal(SIGQUIT, Fairwell);
- signal(SIGTERM, Fairwell);
+ signal(SIGHUP, Farewell);
+ signal(SIGINT, Farewell);
+ signal(SIGQUIT, Farewell);
+ signal(SIGTERM, Farewell);
- while (1) {
+ while (!ReceivedSignal) {
if (*provider)
syslog(LOG_INFO, "Listening as provider %s", provider);
else
@@ -620,5 +610,19 @@ main(int argc, char **argv)
Spawn(prog, acname, exec, ngc, cs, ds, response, sz, optd);
}
+ if (pidfile)
+ remove(pidfile);
+
+ if (ReceivedSignal) {
+ syslog(LOG_INFO, "Received signal %d, exiting", ReceivedSignal);
+
+ signal(ReceivedSignal, SIG_DFL);
+ raise(ReceivedSignal);
+
+ /* NOTREACHED */
+
+ ret = -ReceivedSignal;
+ }
+
return ret;
}
OpenPOWER on IntegriCloud