I don't think run3 can be used in a threaded environment. Looking at the module code, it makes the redirects, then does system() i.e. fork/exec. A thread-safe version would open the streams; fork(); redirect i/o; exec().
The second problem is waiting upon the processes. You'll need a mechanism to catch child notifications and forward them to the interested threads (via Thread::Queue probably).
In the end, it might be smarter to implement a separate job-controller thread to launch and reap the external jobs.
Update. On a second thought, if your workers only ever wait on a single process at a time, you can get away with just the waitpid($pid, 0); and no job control is necessary...
In reply to Re: thread save calling an external command
by oiskuu
in thread thread save calling an external command
by Paul.Unix
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |