Convert signal to sigaction
Replace use of signal function by sigaction.
Description of Patch
Currently, motion is using signal() function.
There is two problems with this implementation
- the effects of signal() call in a multi-threaded process are
- the signal handler is using printf and syslog but these functions
are not safe as defined by POSIX 1003.1-2003 list
A better implementation will be to use sigaction() instead.
In multi-threaded applications using the thread library (libpthread.a),
signal actions are common to all threads within the process. Any thread
calling the sigaction subroutine changes the action to be taken when a
specific signal is delivered to the threads process, that is, to any
thread within the process.
So it looks a good idea to move the signal handler initialization from
motion_loop() to main() instead.
Installation of Patch
patch < filename
Change History of Patch
20050526 First version
Christophe it seems good but needs a lot of testing.
btw SA_NOCLDWAIT should be checked because is not available in all systems, an easy ways is :
act.sa_flags = SA_NOCLDWAIT;
act.sa_flags = 0;
So that will be used in main() ( motion.c ) and in httpd_run() ( webhttpd.c ).
- 26 May 2005
The POSIX spec only defines SA_NOCLDSTOP.
Anyway, I have posted a second version of the patch to handle compilation error when SA_NOCLDSTOP or SA_RESTART is not defined
- 27 May 2005
Http control interface already include your patch in the last patch i've upload to MotionHttpControl
- 26 May 2005
Updated the patch , removing the part of webhttp that is already include in a webhttpd patch.
- 28 May 2005
The httpd part is now in 3.2.2_snap1 sources.
When this is released we will look at the rest of the patch. I need to get some bugfixes out ASAP.
- 03 Jun 2005
This patch is released for testing in motion-3.2.2_snap9
- 02 Aug 2005