From: nobu.nokada@... Date: 2002-12-14T06:37:05+09:00 Subject: Re: Ruby 1.7.3 command output capture problem Hi, At Fri, 13 Dec 2002 07:07:21 +0900, Jason Persampieri wrote: > Right. The problem is specific to rubyw.exe > > rubyw -e "File.open('test.txt','w+') {|f| f.write `dir`}" > > works as expected on 1.6.7, but doesn't work on 1.7.3. rubyw is a GUI mode program which has no console, therefore restoring STDIN/STDOUT would fail, I guess. This patch may fix the problem, but I'd rather use CreateChild() for redirection... Index: win32.c =================================================================== RCS file: /cvs/ruby/src/ruby/win32/win32.c,v retrieving revision 1.75 diff -u -2 -p -r1.75 win32.c --- win32.c 2 Dec 2002 07:57:17 -0000 1.75 +++ win32.c 13 Dec 2002 20:03:37 -0000 @@ -546,5 +546,5 @@ pipe_exec(char *cmd, int mode, FILE **fp /* restore STDIN/STDOUT */ if (reading) { - if (!SetStdHandle(STD_OUTPUT_HANDLE, hSavedStdOut)) { + if (hSavedStdOut && !SetStdHandle(STD_OUTPUT_HANDLE, hSavedStdOut)) { errno = GetLastError(); CloseChildHandle(child); @@ -559,5 +559,5 @@ pipe_exec(char *cmd, int mode, FILE **fp } if (writing) { - if (!SetStdHandle(STD_INPUT_HANDLE, hSavedStdIn)) { + if (hSavedStdIn && !SetStdHandle(STD_INPUT_HANDLE, hSavedStdIn)) { errno = GetLastError(); CloseChildHandle(child); -- Nobu Nakada