win32utils-devel@rubyforge.org
2004-Nov-18 08:10 UTC
[Win32utils-devel] FW: problem with win32 waitpid
Forward from Laurent Julliiard. Any suggestions anyone? Dan >From: Laurent Julliard <Laurent.Julliard@xrce.xerox.com> >Reply-To: laurent@moldus.org >To: djberg96@hotmail.com >Subject: problem with win32 waitpid >Date: Thu, 18 Nov 2004 08:49:51 +0100 > >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