Feature Request: Better daemon behaviour
Description
For better and easier handling of Motion with system init scripts, Motion should be able to write a PID file and setuid() to a configured user, if run as root, like other "real" daemons.
--
MagnusHolmgren - 06 Jun 2006
Follow up
I agree about the PID file thing, I feel it is sorta sloppy to just grap a pid off the process table thus I wrote a patch for this a while back, I'll attach it here.
--
EvilPete - 07 Jul 2006
I've take some lines from your patch and apply to svn 114 , i did some changes as remove the pid file where motion exits , also some checks to avoid problems creating the file ( Permission denied , etc ... ).
--
AngelCarpintero - 10 Oct 2006
On the config part of patch. \n is a valid value for text options. But then it is litterally "\" and followed by "\n". If the config file cannot understand text_left CAMERA 1\nFRONT YARD then I loose an important feature that I use myself.
text_left CAMERA 1\nFRONT YARD
That example writes two lines of text. So \n is a valid value and means new line.
But we should not pick op an actual '\n' as value. It must be the two characters '\' followed by 'n' in the config file to be picked up.
I guess your change is OK for stripping off \n but not '\' 'n'. But you'd better test it.
On PID. I look at your patch. There is one problem. You can start Motion as daemon. And then set it in setup mode via http. Then it continues in daemon but shows the test image in webcam.
But the way you coded it Motion will not remove the PID file when you exit motion from this condition.
pid_file /home/gstreamer/motion.pid is not a good value for the motion-dist.conf
I miss the option of not using a PID file. Maybe it should be default undefined = no PID. And then the /var/run/motion.pid in motion-dist.conf.
Does all newbies and non-techies know what a pid is? Let us call the option process_id_file.
But I am OK adding the feature as such. As long as it is turned off by default if I do not define process_id_file option.
Ok , i followed all your advices and fixes.I've commit already to svn 115.
Closed this feature, if there's any problem open a bug.
--
AngelCarpintero - 10 Oct 2006