Ovid has asked for the wisdom of the Perl Monks concerning the following question:
I'm in quite a serious dilemma with TAPx::Parser. It's getting close to the point of being beta, but there's a nasty Windows bug that I cannot solve because I don't have access to a Windows box and since I have no experience with inter-process communications on Windows, I wouldn't even know where to start.
I have the following code in TAPx::Parser::Source:
use IPC::Open3; use IO::Select; use IO::Handle; #<snip> my $stdout = IO::Select->new(); my $stdout_handle = IO::Handle->new(); $stdout_handle->autoflush(1); $stdout->add( \*STDOUT ); $stdout->add($stdout_handle); if ( my $pid = open3( undef, $stdout_handle, undef, $command ) ) { return TAPx::Parser::Iterator->new($stdout_handle); } else { $self->exit( $? >> 8 ); $self->error("Could not execute ($command): $!"); return; }
This code is intended to merge STDIN and STDOUT and keep them synchronized (no buffering problems). It runs fine on Mac OS X, Linux, FreeBSD, OpenBSD, etc. However, Win32 users keep reporting errors similar to:
# Failed test ''bignum' should parse successfully' # at t/010-regression.t line 2257. # open3: IO::Pipe: Can't spawn-NOWAIT: No such file or directory at C:\TAPx-Parser-0.50_03\blib\lib/TAPx/Parser/Source.pm line 103
(Line 103, not surprisingly, is the IPC::Open3::open3 command.)
I can't debug this since I don't have a Windows box handy. Googling and reading the Perl Cookbook have also not helped. Further, my research on this site shows many people addressing questions about IPC::Open3 shows people posting snippets, but often not fixing the original poster's code. Since I can't test anything, I need to hopefully get this right on the first try :(
The first argument to open3 is undefined since I don't need to write anything to the child. Should I include a handle and simply close it right away? The third argument is undefined because this forces STDERR an STDOUT to merge, which is the desired behavior. I would really like to get TAPx::Parser production ready and this is one of my last major blockers.
As the above code suggests, the $stdout_handle is read in TAPx::Parser::Iterator.
I really hate to be one to say "do my work for me", but I'm really stuck on this one and have no easy way to verify that it works on Windows.
Miscellaneous notes:
I don't know how to capture the exit status with the above code, either. This may not be a big deal, but it would be really nice to solve.
I've tried reading the source of IPC::Cmd, but I can't figure out how he's fixed the Windows problem. I also can't use that as a prerequisite as I need to ensure that no non-core modules are used (there's a desire expressed on the Perl-QA wiki to have a new TAP::Harness in the core and I have grandiose dreams that it's TAPx::Harness).
Update: I forgot to mention that apparently this is apparently only failing for my t/010-regression.t tests. The other tests all appear to be fine (and all use the same open3 command). The difference in the regression tests is that they run a bunch of tests in the t/sample-tests/ directory. So I have a test program, t/010-regression.t, which is run via the open3 command (apparently successfully), which in turn tries to run other tests via the open3 command (unsuccessfully) and generates the error above.
Cheers,
Ovid
New address of my CGI Course.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: IPC::Open3 failure on Win32
by Corion (Patriarch) on Jan 09, 2007 at 19:17 UTC | |
by Ovid (Cardinal) on Jan 09, 2007 at 19:28 UTC | |
by Corion (Patriarch) on Jan 09, 2007 at 19:49 UTC | |
by Ovid (Cardinal) on Jan 09, 2007 at 19:58 UTC | |
by Corion (Patriarch) on Jan 09, 2007 at 20:12 UTC | |
| |
Re: IPC::Open3 failure on Win32
by diotalevi (Canon) on Jan 09, 2007 at 20:49 UTC | |
Re: IPC::Open3 failure on Win32
by zentara (Archbishop) on Jan 09, 2007 at 20:03 UTC | |
by Ovid (Cardinal) on Jan 09, 2007 at 20:15 UTC | |
Re: IPC::Open3 failure on Win32
by Steve_p (Priest) on Jan 10, 2007 at 00:26 UTC | |
Re: IPC::Open3 failure on Win32
by ikegami (Patriarch) on Jan 10, 2007 at 04:59 UTC | |
Re: IPC::Open3 failure on Win32
by talexb (Chancellor) on Jan 10, 2007 at 04:17 UTC | |
Re: IPC::Open3 failure on Win32
by El Linko (Beadle) on Jan 14, 2007 at 23:06 UTC |