bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Process::spawn() and atexit()


From: Ian Gough
Subject: Process::spawn() and atexit()
Date: Fri, 17 Jan 2003 14:28:21 -0500

On Win32, Process::spawn() blocks as it spawns a new process. On all other platforms, it forks, execs and then waits. The side effect comes in that the parent process of the fork then exits, which causes the function set up in atexit() to be called.
 
Normally, this wouldn't cause a problem, but the app I am building is a server that spawns multiple processes and sets up communications links to each of the children. To make sure the system gets shutdown gracefully, in the atexit function I caused the server to tell each of the children to quit gracefully. Now this works fine in Win32, but on unix, due to the forking, the atexit function gets called when the parent process of the fork exits, which causes the shutdown message to be sent to the child processes before the server portion is actually exiting, thereby tearing down half the system.
 
I think that perhaps this side effect needs to be documented for the Process::spawn() method so that people can be aware there are issues with using atexit() and spawn().
 
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]