system() function is implemented by using fork(), execve() and wait() functions.
I have heard that fork() function is dangerous in multi-threaded programs.
So, is the system() function also dangerous in multi-threaded programs?
What problems it may cause?
forkis dangerous in threaded programs unless followed byexecve. Since only the current thread is forked there’s very little you can do in a forked multi-threaded program other thanexecve. You should probably make sure you’re not taking any locks after thefork.Since
system()doesfork+exec, it should be safe.