From 8411a37e7dc72a5fd2e4fb68d1c557dc89253973 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 20 Jun 2007 07:33:26 +0000 Subject: Detach from the TTY properly. --- sysdep/unix/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c index 335f42a1..da1ba37f 100644 --- a/sysdep/unix/main.c +++ b/sysdep/unix/main.c @@ -435,6 +435,11 @@ main(int argc, char **argv) if (pid) return 0; setsid(); + close(0); + if (open("/dev/null", O_RDWR) < 0) + die("Cannot open /dev/null: %m"); + dup2(0, 1); + dup2(0, 2); } signal_init(); -- cgit v1.2.3