We are working on a multithreaded memory-consuming application written in C++. We have to execute lots of shellscript/linux commands (and get the return code).
After reading that article we clearly understood that it would be a bad idea to use system() in our context.
A solution would be to fork after program starts and before creating any threads but the communication with that process may not be easy (socket, pipe ?).
The second solution we considered may consist of a dedicated deamon written in python (using xinetd ?) that would be able to process our system calls.
Have you ever had that problem? How did you solve it?
Note : Here is a more complete article that explain this problem : http://developers.sun.com/solaris/articles/subprocess/subprocess.html They recommend to use posix_spawn which uses vfork() instead of fork() (used in system()).
fork()producing single-threaded child processes even if the parent is multi-threaded, and doesn't say anything aboutsystem()being a bad idea.