aboutsummaryrefslogtreecommitdiffstats
path: root/src/log.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/log.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/log.c b/src/log.c
index fa4ae64f0..974c07146 100644
--- a/src/log.c
+++ b/src/log.c
@@ -40,7 +40,11 @@ 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 || ! isatty(STDIN_FILENO))
+ 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)