summaryrefslogtreecommitdiff
path: root/usr.sbin/wsmoused/wsmoused.h
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2002-01-12 01:15:38 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2002-01-12 01:15:38 +0000
commitbf215359d7a2e6989c8c1126bbca879b66304e97 (patch)
tree60a01fb765b004eb120c8f0123d763a8ec337d90 /usr.sbin/wsmoused/wsmoused.h
parentfa0cc8b62381849ab4c93a5eebdda78c1b827c0d (diff)
Make sure the daemon() call is harmless to file descriptors.
Problem reported by markus@, fix by me, ok markus@ millert@
Diffstat (limited to 'usr.sbin/wsmoused/wsmoused.h')
-rw-r--r--usr.sbin/wsmoused/wsmoused.h33
1 files changed, 19 insertions, 14 deletions
diff --git a/usr.sbin/wsmoused/wsmoused.h b/usr.sbin/wsmoused/wsmoused.h
index 2ad2d6d9ac2..412dd38d3a4 100644
--- a/usr.sbin/wsmoused/wsmoused.h
+++ b/usr.sbin/wsmoused/wsmoused.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmoused.h,v 1.2 2001/12/11 21:10:50 miod Exp $ */
+/* $OpenBSD: wsmoused.h,v 1.3 2002/01/12 01:15:37 miod Exp $ */
/*
* Copyright (c) 2001 Jean-Baptiste Marchand, Julien Montagne and Jerome Verdon
@@ -55,23 +55,28 @@
/* Logging macros */
+extern char *pidfile;
+
#define debug(fmt,args...) \
if (debug&&nodaemon) printf(fmt, ##args)
-#define logerr(e, fmt, args...) { \
- if (background) { \
- syslog(LOG_ERR, fmt, ##args); \
- exit(e); \
- } else \
- errx(e, fmt, ##args); \
-}
+#define logerr(e, fmt, args...) \
+ do { \
+ unlink(pidfile); \
+ if (background) { \
+ syslog(LOG_ERR, fmt, ##args); \
+ exit(e); \
+ } else \
+ errx(e, fmt, ##args); \
+ } while (0)
-#define logwarn(fmt, args...) { \
- if (background) \
- syslog(LOG_WARNING, fmt, ##args); \
- else \
- warnx(fmt, ##args); \
-}
+#define logwarn(fmt, args...) \
+ do { \
+ if (background) \
+ syslog(LOG_WARNING, fmt, ##args); \
+ else \
+ warnx(fmt, ##args); \
+ } while (0)
/* Daemon flags */