LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Using system() with pthreads (https://www.linuxquestions.org/questions/programming-9/using-system-with-pthreads-208886/)

markdhorn 07-23-2004 06:04 PM

Using system() with pthreads
 
Is it safe to use the system() function call from a pthread?

I've inherited some code that is heavily using pthread on a Linux 2.4.10 kernel, but it also has many instances of system("<program>").

The system() call will result in a fork() and execve(). I thought I read some place that it wasn't safe to use execve with threads?

The code will SEGV on occasion, but it is very random and seems to be more frequent based on the load of the system; the more thread running the higher chance that it will SEGV.

Is there a good source to reference on if system() is thread safe?

Any help appreciated!
--mark

jlliagre 07-24-2004 04:02 AM

Solaris manual says system() is not thread safe, and recommend using popen() instead, which is thread-safe.

That may or may not apply to Linux though ...


All times are GMT -5. The time now is 08:04 AM.