dragonfly
dragonfly copied to clipboard
Support for posix-spawn?
Would it be possible to use posix-spawn for shell commands?
It's more efficient than popen3 and provides meaningful process hierarchies because it performs a single fork/exec. (popen3 double forks to avoid needing to collect the exit status and also calls Process::detach which creates a Ruby Thread!!!!).
It handles all max pipe buffer (PIPE_BUF) hang cases when reading and writing semi-large amounts of data. This is non-trivial to implement correctly and must be accounted for with popen3, spawn, or hand rolled fork/exec code.
It's more portable than hand rolled pipe, fork, exec code because fork(2) and exec aren't available on all platforms. In those cases, POSIX::Spawn::Child falls back to using whatever janky substitutes the platform provides.
Hi - looks interesting, though I'd be reluctant to because I want to keep dependencies to a minimum. Was there a specific case where it made a big difference or where popen3 was being problematic? I don't mind popen3 being slightly less efficient if it's not the bottleneck
Another popular image processing library - minimagick, has a plug-in support for it, the dependency being optional. Difference can be huge when dealing with thousands of images.