Ruby under Unix allows me to see if a child process died of a signal.
E.g. ruby 1.8.0 I can check $?.signaled?.
Unlike Unix, under Win32, $?.signaled? is not true when the child dies
of Ctrl-C.
Is this a known, fixable bug or a limitation of Windows?
Ruby under Unix allows me to see if a child process died of a signal.
E.g. ruby 1.8.0 I can check $?.signaled?.
Unlike Unix, under Win32, $?.signaled? is not true when the child dies
of Ctrl-C.
Is this a known, fixable bug or a limitation of Windows?
I wrote this routine for my clutil win.rb lib[1], that calls spawnvp
asynchronously. The async call returns the process handle. “The return value
from a synchronous _spawnv or _wspawnv (_P_WAIT specified for mode) is the
exit status of the new process. … The exit status is 0 if the process
terminated normally. … If the new process did not explicitly set a
positive exit status, a positive exit status indicates an abnormal exit with
an abort or an interrupt.”
So, maybe tweaking what I’ve done below for a sync call will give you a
suitable workraround for what you need – though notice my comment about
segfaults – I haven’t tinkered with this on any newer versions
(1.6.8/1.8.0-preview)
P_WAIT = 0
P_NOWAIT = 1
OLD_P_OVERLAY = 2
P_NOWAITO = 3
P_DETACH = 4
def async_system(command)
···
wnv.asp
this is working – but frequently Segfaults ruby 1.6.6 mswin32
spawn = Win32API.new(“crtdll”, “_spawnvp”, [‘I’, ‘P’, ‘P’] ,‘L’)
res = spawn.Call(P_NOWAIT, command, ‘’)
if res == -1
Win32API.new(“crtdll”, “perror”, [‘P’], ‘V’).call(‘async_system’)
end
res
end
[1] http://clabs.org/dl/clutil/clutil.2003.027.0.zip
Chris
Hello,
In message “Re: win32 + ctrl-c of child processes”
···
on Feb.06,2003 09:46:00, nobu.nokada@softhome.net wrote:
Also command.com/cmd.exe tell you nothing about it, I guess
it’s a limitation of Windows. GetExitCodeProcess() API returns
exit code only. Anyone has more info?
Borland C++Builder’s help says that wait() returns information
about how child process died by using bit 0-7 of status word,
just like same function of UNIX.
But I don’t know how C++Builder gets the information, and also
don’t know whether it works really.
Regards,
U.Nakamura usa@osb.att.ne.jp
“U.Nakamura” usa@osb.att.ne.jp writes:
Hello,
In message “Re: win32 + ctrl-c of child processes”
Also command.com/cmd.exe tell you nothing about it, I guess
it’s a limitation of Windows. GetExitCodeProcess() API returns
exit code only. Anyone has more info?
Borland C++Builder’s help says that wait() returns information
about how child process died by using bit 0-7 of status word,
just like same function of UNIX.
But I don’t know how C++Builder gets the information, and also
don’t know whether it works really.
Actually I just need a way to spawn a child process without blocking
SIGINT.
trap('SIGINT') {
puts "got SIGINT"
}
ret = system('ruby -e "loop {}"')
puts "after system #{ret}"
if $?.exited?
puts "exited with %d" % [ $?.exitstatus ]
end
if $?.signaled?
puts "signaled with %d" % [ $?.termsig ]
end
if $?.coredump?
puts "coredump!"
end
E.g. both Unix and Windows never print “got SIGINT” but under Unix I
can write my own “system” with fork/exec.
I have a separate Win32 C program that installs a SIGINT handler
with signal() before using spawnvp() to spawn a child process. In
this way it receives notice of Ctrl-C. But it does not look like I
can currently do this with Ruby, true?
···
on Feb.06,2003 09:46:00, <nobu.nokada@softhome.net> wrote: