A Ruby library for fast process spawning using posix_spawn() and vfork() to avoid fork() overhead.
posix-spawn is a Ruby library that provides fast process spawning by using system interfaces like `posix_spawn()` and `vfork()` instead of traditional `fork()` calls. It solves the performance problem where `fork()` becomes slow as parent processes use more memory, making it ideal for applications that frequently spawn child processes.
Ruby developers building applications that need to spawn child processes efficiently, such as system tools, background job processors, or services using `Kernel#system`, `IO::popen`, or similar methods.
Developers choose posix-spawn for its significant performance improvements over standard Ruby process spawning methods, especially in memory-intensive applications, while maintaining compatibility with Ruby's native `Process::spawn` interface.
Ruby process spawning library
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses posix_spawn() and vfork() to avoid the page table copy overhead of fork(), ensuring spawn times remain constant regardless of parent process memory size, as shown in Linux benchmarks.
Implements a large subset of Ruby 1.9's Process::spawn interface, making it easy for developers familiar with modern Ruby to adopt without a steep learning curve.
Provides optimized versions of Kernel#system, Kernel#`, and IO::popen for Ruby >= 1.8.7, offering performance improvements in common shell command execution scenarios.
Includes POSIX::Spawn::Child for straightforward non-streaming IPC with automatic input/output handling and timeout support, reducing code complexity for simple cases.
Lacks support for advanced Process::spawn options like resource limits (rlimit), umask settings, and certain redirection methods, as admitted in the STATUS section.
The :chdir option is not thread-safe when using posix_spawn, requiring the library to change the calling process's working directory, which can cause issues in concurrent environments.
Performance benefits are tied to system interfaces like posix_spawn and vfork; on systems without these, fallback implementations may not deliver the same speed improvements.