I’m working on a Sidekiq worker that’s sole purpose is to make several long-running system calls. I have the following requirements:
- Able to set environment variables
- Real-time output (stdout, stderr) stream
- Block thread until finished
- Get exit code
- Thread-safe, since sidekiq is multi-threaded (read: no
$?)
I’m running on Ruby 1.9.2. Thanks for your input!
$?(as well as most other “magical” variables like$1etc.) is local to the current thread and thus usingsystemand$?is perfectly thread-safe and meets all your criteria.