From: Chris Morris Date: 2003-02-06T23:19:59+09:00 Subject: Re: win32 + ctrl-c of child processes > 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) # http://msdn.microsoft.com/library/en-us/vccore98/html/_crt__spawnv.2c_._wspa 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