`system': no implicit conversion from nil to integer (TypeError)
from wifi-state-observer:169:in `vpn_down'
from wifi-state-observer:46:in `block in run'
from wifi-state-observer:54:in `call'
from wifi-state-observer:54:in `run'
from wifi-state-observer:54:in `run'
from wifi-state-observer:270:in `<main>'
Looking at Ruby's source:
it seems like rb_last_status_get() might be non-thread safe? Though I
would expect at that time the GVL would held so I am not sure why would
rb_last_status_get() return nil. This is running 1.9.3.
`system': no implicit conversion from nil to integer (TypeError)
from wifi-state-observer:169:in `vpn_down'
from wifi-state-observer:46:in `block in run'
from wifi-state-observer:54:in `call'
from wifi-state-observer:54:in `run'
from wifi-state-observer:54:in `run'
from wifi-state-observer:270:in `<main>'
Looking at Ruby's source:
Can we first look at your call to system and surrounding code?
Any ideas?
Not yet.
Kind regards
robert
···
On Fri, Aug 24, 2012 at 6:04 AM, <rgs@rieder.net.py> wrote:
Considering the message about conversion from nil to integer, I'd expect
the problem to be that either "cmd" or "@ncui_pid" is returning nil and
can't be passed into the system command.
Can you add a line which puts the cmd value out before triggering the
system command and report it back? It still looks like the only way to
get that error in this code is to pass something invalid to system.
`system': no implicit conversion from nil to integer (TypeError)
from wifi-state-observer:169:in `vpn_down'
from wifi-state-observer:46:in `block in run'
from wifi-state-observer:54:in `call'
from wifi-state-observer:54:in `run'
from wifi-state-observer:54:in `run'
from wifi-state-observer:270:in `<main>'
Looking at Ruby's source:
Can we first look at your call to system and surrounding code?
cmd won't be nil and if @ncui_pid is nil this won't matter.
Kind regards
robert
···
On Tue, Aug 28, 2012 at 2:12 PM, Joel Pearson <lists@ruby-forum.com> wrote:
Considering the message about conversion from nil to integer, I'd expect
the problem to be that either "cmd" or "@ncui_pid" is returning nil and
can't be passed into the system command.
It seems Process.waitall takes the child process spawned by system().
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 <main>'
from -e:3:in `loop'
from -e:3:in `<main>'
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 <main>'
from -e:3:in `loop'
from -e:3:in `<main>'
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
···
On 29 August 2012 01:30, Tanaka Akira <akr@fsij.org> wrote: