aboutsummaryrefslogtreecommitdiffstats
path: root/src/listen.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-12-30 16:28:13 +0100
committerMax Kellermann <max@duempel.org>2008-12-30 16:28:13 +0100
commit6c0f5fc6125a478fd50074880ed7fcac9fd9063e (patch)
tree0249671839bc1ccf0211838fab4f9176d59aa026 /src/listen.c
parent671480814c643cd094978e4a0db76687fbddec4f (diff)
downloadmpd-6c0f5fc6125a478fd50074880ed7fcac9fd9063e.tar.gz
mpd-6c0f5fc6125a478fd50074880ed7fcac9fd9063e.tar.xz
mpd-6c0f5fc6125a478fd50074880ed7fcac9fd9063e.zip
listen: moved redirect_stdin() to daemon.c
redirect_stdin() is a daemonization function, and disconnecting from the standard input is always a good idea for MPD.
Diffstat (limited to 'src/listen.c')
-rw-r--r--src/listen.c29
1 files changed, 0 insertions, 29 deletions
diff --git a/src/listen.c b/src/listen.c
index 67a40f95c..31067ce5a 100644
--- a/src/listen.c
+++ b/src/listen.c
@@ -49,34 +49,6 @@ static int *listenSockets;
static int numberOfListenSockets;
int boundPort;
-/*
- * redirect stdin to /dev/null to work around a libao bug
- * there are likely other bugs in other libraries (and even our code!)
- * that check for fd > 0, so it's easiest to just keep
- * fd = 0 == /dev/null for now...
- */
-static void redirect_stdin(void)
-{
- int fd, st;
- struct stat ss;
-
- if ((st = fstat(STDIN_FILENO, &ss)) < 0) {
- if ((fd = open("/dev/null", O_RDONLY) > 0)) {
- g_debug("stdin closed, and could not open /dev/null "
- "as fd=0, some external library bugs "
- "may be exposed...");
- close(fd);
- }
- return;
- }
- if (!isatty(STDIN_FILENO))
- return;
- if ((fd = open("/dev/null", O_RDONLY)) < 0)
- g_error("failed to open /dev/null %s", strerror(errno));
- if (dup2(fd, STDIN_FILENO) < 0)
- g_error("dup2 stdin: %s", strerror(errno));
-}
-
static int establishListen(int pf, const struct sockaddr *addrp,
socklen_t addrlen)
{
@@ -245,7 +217,6 @@ void listenOnPort(void)
boundPort = port;
- redirect_stdin();
do {
parseListenConfigParam(port, param);
} while ((param = getNextConfigParam(CONF_BIND_TO_ADDRESS, param)));