[patch] detach from controlling tty in non-debug mode
Ondrej Filip
feela at network.cz
Wed Jun 20 14:17:47 CEST 2007
Florian Lohoff wrote:
> Hi,
> bird needs something like this because in case it daemonizes it still
> keeps the fds open of the controlling tty which is bad in case you'd
> like to log out which then will hang.
>
> I already opened a Debian Bug - See:
>
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=427772
>
> Flo
Thank you. This will be fixed in next release.
Ondrej
>
> diff -Nur bird-1.0.11/sysdep/unix/main.c bird-1.0.11.flo/sysdep/unix/main.c
> --- bird-1.0.11/sysdep/unix/main.c 2007-06-20 09:13:21.000000000 +0200
> +++ bird-1.0.11.flo/sysdep/unix/main.c 2007-06-20 09:21:00.000000000 +0200
> @@ -434,7 +434,18 @@
> die("fork: %m");
> if (pid)
> return 0;
> +
> setsid();
> +
> + /* Close all FDs and thus detach from controlling tty */
> + for (i=getdtablesize();i>=0;--i)
> + close(i);
> +
> + /* create harmless stdin/out/err */
> + i=open("/dev/null",O_RDWR);
> + dup(i);
> + dup(i);
> +
> }
>
> signal_init();
More information about the Bird-users
mailing list