aboutsummaryrefslogtreecommitdiffstats
path: root/src/daemon.h
diff options
context:
space:
mode:
authorMichal Nazarewicz <mina86@mina86.com>2009-07-22 13:43:21 +0200
committerMax Kellermann <max@duempel.org>2009-07-22 13:43:21 +0200
commitbfed1c04cc13ec01fa7bb6c250662f5dfb8c7931 (patch)
tree093babf82dd46a048db315704006d8e01d135fce /src/daemon.h
parentbdb1965b506ee97e7e8a07253e29c2f4cc3d6bf6 (diff)
downloadmpd-bfed1c04cc13ec01fa7bb6c250662f5dfb8c7931.tar.gz
mpd-bfed1c04cc13ec01fa7bb6c250662f5dfb8c7931.tar.xz
mpd-bfed1c04cc13ec01fa7bb6c250662f5dfb8c7931.zip
daemon: daemonize_close_stdin() optimised.
Changed function to first close standard input (this may fail but we don't care) and then try to open /dev/null (this may fail but it shouldn't on Unix platforms plus we don't know what to do in such case anyways). Since standard input has the "zeroth" descriptor number next "open" will use it. Since there is no "/dev/null" on Windows (It's not even a valid path!) the second step is skipped if WIN32 is defined. As a final touch, since the function consists of merely two function calls it has been moved to header file and declared static inline. [mk: un-inline daemonize_close_stdin()]
Diffstat (limited to 'src/daemon.h')
-rw-r--r--src/daemon.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/daemon.h b/src/daemon.h
index 1332eaf48..a29945607 100644
--- a/src/daemon.h
+++ b/src/daemon.h
@@ -56,8 +56,13 @@ daemonize_kill(void)
/**
* Close stdin (fd 0) and re-open it as /dev/null.
*/
+#ifndef WIN32
void
daemonize_close_stdin(void);
+#else
+static inline void
+daemonize_close_stdin(void) {}
+#endif
/**
* Change to the configured Unix user.