Motion should detach from standard in and standard out when going daemon
Introduction
From IRC channel #motion 1 oct 2004
[23:09] <ctrl-l> fd 0 is still attached in daemon mode
[23:10] <Lavr> fd 0 ?
[23:10] <ctrl-l> hmm stdout?
[23:10] <Lavr> Hmm. never noticed.
[23:10] <ctrl-l> or stdin.. can't remeber what was it
[23:11] <ctrl-l> When i launch it from ssh tty, it's still attached to tty and my window wont go away
[23:12] <Lavr> Ah. Yes. That is a common problem when running many programs from SSH. I have seen that with others also.
[23:13] <ctrl-l> ls -l /proc/<pid>/fd/ ...
[23:13] <Lavr> Does it ALWAYS fo this for you?
[23:13] <ctrl-l> yes
[23:14] <Lavr> You get the commend prompt back after starting Motion but just cannot get the SSH tty stopped?
[23:14] <ctrl-l> here is a code which closes stdin,out,err:
[23:14] <ctrl-l> i = open("/dev/null", O_RDWR);
[23:14] <ctrl-l> if (i)
[23:14] <ctrl-l> dup2(i, 0);
[23:14] <ctrl-l> dup2(i, 1);
[23:14] <ctrl-l> dup2(i, 2);
[23:14] <ctrl-l> if (i)
[23:14] <ctrl-l> close(i);
[23:15] <ctrl-l> correct
[23:15] <Lavr> I will consider adding this somewhere when daemon is on. Good hint.
Description of Patch
Patch detach device 0, 1 and 2.
Installation of Patch
patch -p1 < daemon-detach-dev012.patch
Needs to be verified on FreeBSD
--
KennethLavrsen - 01 Oct 2004
AngelCarpintero has tested it on FreeBSD. It is in my 3.1.17 source tree ready for release.
--
KennethLavrsen - 06 Oct 2004