From: "Raúl Gutiérrez Segalés" Date: 2012-09-04T12:11:26+09:00 Subject: Re: Is calling system() from a thread suppose to be safe? Hi Tanaka! On 29 August 2012 01:30, Tanaka Akira wrote: > 2012/8/25 Raúl Gutiérrez Segalés : > >> Sure, here is the full-script: >> >> http://www.itevenworks.net/~rgs/ruby/wifi-state-observer >> >> system() happens inside vpn_down(). As you can see the main thread is >> glib2 loop and the other forks/execs a binary (that connects to a >> vpn). > > It seems Process.waitall takes the child process spawned by system(). It does! > > In my environment, the problem can be reproducible as follows, > sometimes (not always): > > % ruby -ve ' > Thread.new { loop { p Process.waitall } } > loop { p system("true") } > ' > ruby 2.0.0dev (2012-08-15 trunk 36702) [x86_64-linux] > -e:3: warning: instance variable status not initialized > -e:3:in `system': no implicit conversion from nil to integer (TypeError) > from -e:3:in `block in
' > from -e:3:in `loop' > from -e:3:in `
' > > How about avoiding Process.waitall? > > I feel the error message can be improved, though. Yup - that would be helpful.. maybe we can add something to the docs about missing system and waitall too? Thanks! - rgs