aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQball Cow <qball@qballcow.nl>2007-08-19 16:42:52 +0000
committerQball Cow <qball@qballcow.nl>2007-08-19 16:42:52 +0000
commitd551fa7b3e0fd711794c5d490977fda30ba13d6f (patch)
treeadaa3f9485ceca4e2419a6f9f5772cb5825bbd66
parentc42ff8e2d29d7da3f8790639964b3ca43c1d797a (diff)
downloadmpd-d551fa7b3e0fd711794c5d490977fda30ba13d6f.tar.gz
mpd-d551fa7b3e0fd711794c5d490977fda30ba13d6f.tar.xz
mpd-d551fa7b3e0fd711794c5d490977fda30ba13d6f.zip
Adding the simple patch 1534
git-svn-id: https://svn.musicpd.org/mpd/branches/q-mpd@6762 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--PATCHES1
-rw-r--r--src/log.c8
2 files changed, 8 insertions, 1 deletions
diff --git a/PATCHES b/PATCHES
index d1ddee144..c53fa1550 100644
--- a/PATCHES
+++ b/PATCHES
@@ -2,3 +2,4 @@ Following patches are applied:
* 1478
* 1520
* wavpack endian fix
+* 1534
diff --git a/src/log.c b/src/log.c
index 7701da3a5..72c58622e 100644
--- a/src/log.c
+++ b/src/log.c
@@ -40,7 +40,13 @@ static const char *err_filename;
/* redirect stdin to /dev/null to work around a libao bug */
static void redirect_stdin(void)
{
- int fd;
+ int fd, st;
+ struct stat ss;
+
+ if ((st = fstat(STDIN_FILENO, &ss)) < 0 || /* If STDIN is already closed (e.g. mpd launched in a non-interactive shell) */
+ ! isatty(STDIN_FILENO)) { /* ... or FD 0 does not correspond to a tty device */
+ return; /* ... do nothing and return. */
+ }
if ((fd = open("/dev/null", O_RDONLY)) < 0)
FATAL("failed to open /dev/null %s\n", strerror(errno));
if (dup2(fd, STDIN_FILENO) < 0)