win32utils-devel@rubyforge.org
2004-Nov-18 09:37 UTC
[Win32utils-devel] Forward from Laurent Julliard
Let''s try that again, without Hotmail''s crappy formatting. Dan, I am one of the developer of the FreeRIDE project (the Ruby IDE) and I''m in charge of the FreeRIDE debugger with which we have had a number of problems on Windows now mostly due to the clunky implementation of IO/Process/Signal stuff on Win32. I recently came across your Win32 utils package and investigated the use of win32 process as a replacement for the native Ruby implementation. I currently have a problem which is the following: Somewhere in my code I have this: require ''win32/process'' command = "start CMD /K ruby -e ''while true { sleep 0.1; }''" @inp = @out = IO.popen(command,"w+") # this is the regular Ruby popen #.... getting the pid of the ruby process (pid variable) Process.waitpid(pid) puts "Process stopped" exit When I run this code I always get the following error: waitpid: no child process (Process::Win32::ProcessError) I suspect that the reason for that is because the command I run actually starts a CMD.exe program which in turn starts a ruby program. The waitpid call operates on the pid of the ruby program which is not the child but the grand-child of the current process. If I use the standard Ruby waitpid it works well. Do you see how I can solve this problem? Shall I use Process.create with CREATE_NEW_CONSOLE flag instead of the IO.popen method? Would this work better? Any advice is welcome. Thanks for your help Laurent -- Laurent JULLIARD Xerox Global Services Manager, Smart Document Engineering Tel: +33 (0)4 76 61 50 48 Fax: +33 (0)4 76 61 51 99
win32utils-devel@rubyforge.org
2004-Nov-18 10:08 UTC
[Win32utils-devel] Forward from Laurent Julliard
Hi,> Let''s try that again, without Hotmail''s crappy formatting. > > Dan, > > I am one of the developer of the FreeRIDE project (the Ruby IDE) and I''m > in charge of the FreeRIDE debugger with which we have had a number of > problems on Windows now mostly due to the clunky implementation of > IO/Process/Signal stuff on Win32. I recently came across your Win32 > utils package and investigated the use of win32 process as a replacement > for the native Ruby implementation. I currently have a problem which is > the following: Somewhere in my code I have this: > > require ''win32/process'' > command = "start CMD /K ruby -e ''while true { sleep 0.1; }''" > @inp = @out = IO.popen(command,"w+") # this is the regular Ruby popen > > #.... getting the pid of the ruby process (pid variable) > Process.waitpid(pid) > puts "Process stopped" > > exit > > When I run this code I always get the following error: > > waitpid: no child process (Process::Win32::ProcessError) > > I suspect that the reason for that is because the command I run actually > starts a CMD.exe program which in turn starts a ruby program. The > waitpid call operates on the pid of the ruby program which is not the > child but the grand-child of the current process. If I use the standard > Ruby waitpid it works well. Do you see how I can solve this problem? > Shall I use Process.create with CREATE_NEW_CONSOLE flag instead of the > IO.popen method? Would this work better? Any advice is welcome. > > Thanks for your help > > Laurent > --The Process.waitpid of Win32::Process is only usable for pids generated by Win32::fork call. Win32::Process handles it''s own array of pids not compatible with ruby native array of pids. So you cannot mix Win32::Process.wait and IO.popen. Regards, Park Heesob