Ton Hospel wrote:
>In article <[EMAIL PROTECTED]>,
> Steve Hay <[EMAIL PROTECTED]> writes:
>
>
>>Adding some debug, I find that $sel->can_read() is returning an empty
>>list. If I change
>>
>> while (my @ready = $sel->can_read) {
>> foreach my $fh (@ready) { # loop through buffered handles
>> ...
>> }
>> }
>>
>>to
>>
>> foreach my $fh ($outfh, $errfh) {
>> ...
>> }
>>
>>then the output is now as expected.
>>
>>Presumably IO::Select->can_read() doesn't work on Win32 because it uses
>>a 4-arg select(), which is only implemented for sockets on Win32. Is
>>the above change safe, or did we need to call can_read() for some
>>reason? Would the proposed "selectable pipes" change have any impact on
>>this?
>>
>>
>>
>The case where the above type of change is dangerous is when the source
>tries to write more than can be buffered in the communication channel to
>err_fh and only then bothers to write to $out_fh. In that case you will
>deadlock. the source will wait until enough gets drained from err_fh so it
>can write again, and you will wait on $out_fh, which hasn't gotten anything
>yet and now never will.
>
>So whether that is relevant for your case depends on what you're running
>(how it uses its output channels).
>
I don't know what commands are being run by IPC::Cmd and whether or not
they would be likely to be affected by these problems, but I guess
removing the can_read() check isn't ideal if it *can* cause problems,
even if it doesn't affect us now -- we'd only be storing up problems for
the future.
Does anyone know if the selectable pipes work that Nicholas mentioned
would be likely to make the 4-arg select(), and hence can_read(), work?
I don't really know what would be involved in finishing off the work in
question, but if someone can give me some pointers then I'm willing to
give it a go.
Alternatively, Nicholas also mentioned the possibility of converting the
C code to Perl (and indeed, actually did so) and putting that into
IPC::Run. Again, I've no idea how to fit that Perl code into IPC::Run
(or IPC::Cmd). Can someone help out?
- Steve
------------------------------------------------
Radan Computational Ltd.
The information contained in this message and any files transmitted with it are
confidential and intended for the addressee(s) only. If you have received this
message in error or there are any problems, please notify the sender
immediately. The unauthorized use, disclosure, copying or alteration of this
message is strictly forbidden. Note that any views or opinions presented in
this email are solely those of the author and do not necessarily represent
those of Radan Computational Ltd. The recipient(s) of this message should
check it and any attached files for viruses: Radan Computational will accept no
liability for any damage caused by any virus transmitted by this email.