Permalink
Browse files

$? is thread-local in 1.9

  • Loading branch information...
1 parent 0a65ce9 commit 2bd49f5bbfd9d0f6aa9c23fdaa682dfbffe31745 @jfirebaugh jfirebaugh committed May 7, 2012
Showing with 14 additions and 3 deletions.
  1. +0 −1 kernel/common/global.rb
  2. +1 −1 kernel/common/process.rb
  3. +6 −0 kernel/common/process18.rb
  4. +7 −0 kernel/common/process19.rb
  5. +0 −1 kernel/delta/kernel.rb
@@ -24,7 +24,6 @@ def initialize
@internal[:$"] = loaded_features
@internal[:$,] = nil # Output field separator
@internal[:$.] = 0
- @internal[:$?] = nil # Process status. nil until set
@internal[:$=] = false # ignore case, whatever that is
@internal[:$0] = nil
@internal[:$CONSOLE] = STDOUT
@@ -337,7 +337,7 @@ def self.wait2(input_pid=-1, flags=nil)
status, termsig, stopsig, pid = value
status = Process::Status.new(pid, status, termsig, stopsig)
- Rubinius::Globals.set! :$?, status
+ set_status_global status
[pid, status]
end
@@ -1,4 +1,10 @@
module Process
+ Rubinius::Globals.read_only :$?
+
+ def self.set_status_global(status)
+ Rubinius::Globals.set! :$?, status
+ end
+
def self.exec(cmd, *args)
if args.empty? and cmd.kind_of? String
raise Errno::ENOENT if cmd.empty?
@@ -242,6 +242,13 @@ def self.exec(env, prog, argv, redirects, options)
end
module Process
+ Rubinius::Globals.read_only :$?
+ Rubinius::Globals.set_hook(:$?) { Thread.current[:$?] }
+
+ def self.set_status_global(status)
+ Thread.current[:$?] = status
+ end
+
def self.daemon(stay_in_dir=false, keep_stdio_open=false)
# Do not run at_exit handlers in the parent
exit!(0) if fork
@@ -136,7 +136,6 @@ def method_missing(meth, *args)
Rubinius::Globals.read_only :$:, :$LOAD_PATH, :$-I
Rubinius::Globals.read_only :$", :$LOADED_FEATURES
Rubinius::Globals.read_only :$<
- Rubinius::Globals.read_only :$?
Rubinius::Globals[:$-a] = false
Rubinius::Globals[:$-l] = false

0 comments on commit 2bd49f5

Please sign in to comment.