summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-10-20 10:46:43 +0900
committerKoichi Sasada <ko1@atdot.net>2020-10-20 15:38:54 +0900
commit99310e3eb56fbc85bb45119285812eb959448d0c (patch)
treeae11ca7bf99ff3b1d60d297c63d64e0540fe51c0 /process.c
parent9ced5fae6df9e70506ddad822e15745884e365fd (diff)
Some global variables can be accessed from ractors
Some global variables should be used from non-main Ractors. [Bug #17268] ```ruby # ractor-local (derived from created ractor): debug '$DEBUG' => $DEBUG, '$-d' => $-d, # ractor-local (derived from created ractor): verbose '$VERBOSE' => $VERBOSE, '$-w' => $-w, '$-W' => $-W, '$-v' => $-v, # process-local (readonly): other commandline parameters '$-p' => $-p, '$-l' => $-l, '$-a' => $-a, # process-local (readonly): getpid '$$' => $$, # thread local: process result '$?' => $?, # scope local: match '$~' => $~.inspect, '$&' => $&, '$`' => $`, '$\'' => $', '$+' => $+, '$1' => $1, # scope local: last line '$_' => $_, # scope local: last backtrace '$@' => $@, '$!' => $!, # ractor local: stdin, out, err '$stdin' => $stdin.inspect, '$stdout' => $stdout.inspect, '$stderr' => $stderr.inspect, ```
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3670
Diffstat (limited to 'process.c')
-rw-r--r--process.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/process.c b/process.c
index 8abb3ea86f..90db3c5677 100644
--- a/process.c
+++ b/process.c
@@ -8445,6 +8445,10 @@ InitVM_process(void)
#define rb_intern(str) rb_intern_const(str)
rb_define_virtual_variable("$?", get_CHILD_STATUS, 0);
rb_define_virtual_variable("$$", get_PROCESS_ID, 0);
+
+ rb_gvar_ractor_local("$$");
+ rb_gvar_ractor_local("$?");
+
rb_define_global_function("exec", f_exec, -1);
rb_define_global_function("fork", rb_f_fork, 0);
rb_define_global_function("exit!", rb_f_exit_bang, -1);