aboutsummaryrefslogtreecommitdiffstats
path: root/src/log.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/log.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/log.c b/src/log.c
index 1405ba301..e654d1941 100644
--- a/src/log.c
+++ b/src/log.c
@@ -39,13 +39,27 @@ static int err_fd = -1;
static const char *out_filename;
static const char *err_filename;
-/* redirect stdin to /dev/null to work around a libao bug */
+/*
+ * 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 || ! isatty(STDIN_FILENO))
+ if ((st = fstat(STDIN_FILENO, &ss)) < 0) {
+ if ((fd = open("/dev/null", O_RDONLY) > 0))
+ DEBUG("stdin closed, and could not open /dev/null "
+ "as fd=0, some external library bugs "
+ "may be exposed...\n");
+ close(fd);
+ }
+ return;
+ }
+ if (!isatty(STDIN_FILENO))
return;
if ((fd = open("/dev/null", O_RDONLY)) < 0)
FATAL("failed to open /dev/null %s\n", strerror(errno));