Skip Menu |

This queue is for tickets about the IO-Callback CPAN distribution.

Report information
The Basics
Id: 96534
Status: open
Priority: 0/
Queue: IO-Callback

People
Owner: Nobody in particular
Requestors: mss [...] apache.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.12
Fixed in: (no value)



Subject: FYI: XS code which fails to run with IO::Callback: Win32::Job
The docs say "Fails to inter-operate with some library modules that read or write filehandles from within XS code. I am aware of the following specific cases, please let me know if you run into any others" so here's another one: Win32::Job Testcase below (stripped down version of the script I was working on). Call it as perl test.pl 1 and it the command will exit with an error. Call it as perl test.pl 0 and a file test.out will be created and everything is fine. use strict; use warnings; use 5.010; use Win32::Job; use IO::Callback; use IO::File; sub main { my $use_ioc = $_[0] // 1; my $stdxxx = sub { my($type) = @_; if ($use_ioc) { return IO::Callback->new('>', sub { my($data, $type) = @_; $data =~ tr/\r//d; $data =~ s/^/$type /gm; return print($data) or IO::Callback::Error; }, $type); } else { return IO::File->new('test.' . $type, 'w'); } }; my $stdout = $stdxxx->('out') or die $!; my $stderr = $stdxxx->('err') or die $!; $stdout->print("bar\n"); my $exe = "cmd.exe"; my $job = Win32::Job->new or die "Failed to create job: $^E"; say "Running " . join(' ', $exe); my $pid = $job->spawn( $exe, join(' ', $exe, qw(/c "echo foo")), { no_window => 1, stdin => 'nul', stdout => $stdout, stderr => $stderr, }, ) or die "Failed to spawn job: $^E"; $job->watch( sub { say "."; return 0; }, 1, ) or die "Killed"; my $status = $job->status; my $result = $status->{$pid}->{'exitcode'}; say $result; return $result; } $| = 1; exit main() // 0; __END__
I don't have a Win32 machine to test this on, but could this be a case of a more general limitation? Tied handles can't be inherited by another process. Is Win32::Job running another process and expecting it to write to the handles you pass it? See http://www.perlmonks.org/?node_id=757524