I’ve been looking around on the internet trying to find a way to make concurrent calls to an external program in a thread safe manner from within my C++ program.
As far as I’ve understood, popen, system and fork are not thread safe.
It seems to me that there is something missing here, that I haven’t been able to find so far. Is it possible that there is NO WAY to make concurrent calls from different threads to an external program? Because it seems to me that this would be one of the first examples of usage of multi-thread coding.
I am using linux (mandriva) and the external program I wish to call can be called in different shells at the same time.
I am not new to C++ but am new to multi-threading , so I would greatly appreciate any advice on the subject.
Marcelo
I’ve been looking around on the internet trying to find a way to make
Share
What makes you think that popen, system and fork are thread-unsafe? A quote from the man page on fork:
If you call system your thread will block until the child process exits. If you want to launch multiple external commands in parallel you can just start 10 threads which call system.