A question for you Ruby nerds: the $? variable gives access to the exit code for the last process launched by Ruby. Is referencing $? a race condition in a system with many threads launching many subprocesses? If it is truly a global variable, then it’s inherently unsafe, but it could also be implemented with a thread-local variable. Any idea which it is?
output = `#{command}`
if $? != 0 # Race condition?
raise output
end

2 responses so far ↓
1 Robert // May 23, 2008 at 1:44 pm
$? is thread-local, see http://www.ruby-doc.org/stdlib/libdoc/English/rdoc/index.html
2 mperham // May 23, 2008 at 2:34 pm
Good catch, thanks Rob.
Leave a Comment