summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/log.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2003-12-20 18:32:23 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2003-12-20 18:32:23 +0000
commitcdd18f79892d68eee65afb88d3377ad2d958f0b2 (patch)
tree824b77476ff74005409a9d5399aa895108b8bcd0 /usr.sbin/bgpd/log.c
parent5343ef6c9154245825c0d18aae6d26059b7dce1b (diff)
keep track which process we are so fatal() can log in which proc the
condition happened. fatal()s from subsystems used by all 3 processes like the imsg subsystem were hard to track down without knowing in which process the condition happened.
Diffstat (limited to 'usr.sbin/bgpd/log.c')
-rw-r--r--usr.sbin/bgpd/log.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/usr.sbin/bgpd/log.c b/usr.sbin/bgpd/log.c
index b3ee25824e3..60af8d26c8b 100644
--- a/usr.sbin/bgpd/log.c
+++ b/usr.sbin/bgpd/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.2 2003/12/17 18:11:31 henning Exp $ */
+/* $OpenBSD: log.c,v 1.3 2003/12/20 18:32:22 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -101,6 +101,12 @@ static const char *suberr_update_names[] = {
"AS-Path unacceptable"
};
+static const char *procnames[] = {
+ "parent",
+ "SE",
+ "RDE"
+};
+
int debug;
char *log_fmt_peer(struct peer *);
@@ -193,16 +199,20 @@ void
fatal(const char *emsg, int error)
{
if (emsg == NULL)
- logit(LOG_CRIT, "%s", strerror(error));
+ logit(LOG_CRIT, "fatal in %s: %s", procnames[bgpd_process],
+ strerror(error));
else
if (error)
- logit(LOG_CRIT, "%s: %s", emsg, strerror(error));
+ logit(LOG_CRIT, "fatal in %s: %s: %s",
+ procnames[bgpd_process], emsg, strerror(error));
else
- logit(LOG_CRIT, "%s", emsg);
+ logit(LOG_CRIT, "fatal in %s: %s",
+ procnames[bgpd_process], emsg);
- /* XXX check which process we are and notify others! */
- sleep(10);
- _exit(1);
+ if (bgpd_process == PROC_MAIN)
+ exit(1);
+ else /* parent copes via SIGCHLD */
+ _exit(1);
}
void