summaryrefslogtreecommitdiff
path: root/os/daemon.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2009-06-16 08:16:27 -0700
committerAlan Coopersmith <alan.coopersmith@sun.com>2009-06-16 08:16:27 -0700
commitc8f86a023411c3697fe86beb4be1fe7fffc7e487 (patch)
treed670cef7f37163026083135ca734759243d844bf /os/daemon.c
parent33c5f6836d8233f91b2c3890ef8419894b7a94d0 (diff)
daemon(): use configure to see if it exists, FatalError on failure
Matches similar changes to xdm's copy of daemon.c Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Diffstat (limited to 'os/daemon.c')
-rw-r--r--os/daemon.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/os/daemon.c b/os/daemon.c
index 94af432..28d8503 100644
--- a/os/daemon.c
+++ b/os/daemon.c
@@ -37,17 +37,16 @@ from the X Consortium.
#include "os.h"
-#if defined(__GLIBC__) || defined(CSRG_BASED)
-#define HAS_DAEMON
-#endif
-
/* detach */
void
BecomeDaemon (void)
{
/* If our C library has the daemon() function, just use it. */
-#ifdef HAS_DAEMON
- daemon (0, 0);
+#ifdef HAVE_DAEMON
+ if (daemon (0, 0) < 0) {
+ /* error */
+ FatalError("daemon() failed, %s\n", strerror(errno));
+ }
#else
switch (fork()) {
@@ -80,5 +79,5 @@ BecomeDaemon (void)
(void) dup2 (0, 1);
(void) dup2 (0, 2);
-#endif /* HAS_DAEMON */
+#endif /* HAVE_DAEMON */
}