Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

IPC::Open3: differences among replies of a background process

by cramdorgi (Acolyte)
on Dec 13, 2008 at 22:05 UTC ( [id://730212]=perlquestion: print w/replies, xml ) Need Help??

cramdorgi has asked for the wisdom of the Perl Monks concerning the following question:

I work on a CPAN module interfacing the proprietary 'cleartool': ClearCase::Argv
I am interested in the mode in which it forks a background process, using IPC::Open3, and sends it requests.
This works mostly fine, but I now meet a problem on Windows, and specifically with interactive comments: certain commands will request a comment from the user. My problem: the mechanism which successfully reads the replies fails to return me the prompt: it hangs.
I don't know what to suspect: flushing, line termination...?
The code works on unix, and on Windows for non interactive commands.
Here are a few shell inliners showing the problem. The 'layer' used with binmode affects as well (:crlf, :win32 :utf8, etc.).
Most cases, I had to interrupt. The others returned, but with no visible ouput (CR evaluation?)
My prompt shows the drive mapped to a ClearCase 'dynamic view'. The command I use replaces a comment in a README file found locally. I give first an example of the dialog as it happens directly on the command line. I end my answer with a line containing a single '.'.
O:\atcctest\ClearCase-Argv>cleartool chevent -rep README Comments for "README": . Modified event of version "README".
The 'prompt' I expect to read is thus here 'Comment for "README":'
O:\atcctest\ClearCase-Argv>perl -MIPC::Open3 -e open3($i,$o,0,qw(clear +tool));binmode $o, q(:crlf);print $i qq(chevent -rep README\n);$a=<$o +>;print $i qq(.\n);chomp($a);$a=~s/\r\n?$//;print qq($a\n);print $i q +(exit\n)" Terminating on signal SIGINT(2) O:\atcctest\ClearCase-Argv>perl -MIPC::Open3 -e open3($i,$o,0,qw(clear +tool));binmode $o, q(:win32);print $i qq(chevent -rep README\n);$a=<$ +o>;print $i qq(.\n);chomp($a);$a=~s/\r\n?$//;print qq($a\n);print $i +qq(exit\n)" O:\atcctest\ClearCase-Argv>perl -MIPC::Open3 -e open3($i,$o,0,qw(clear +tool));binmode $o, q(:utf8);print $i qq(chevent -rep README\n);$a=<$o +>;print $i qq(.\n);chomp($a);$a=~s/\r\n?$//;print qq($a\n);print $i q +q(exit\n)" Terminating on signal SIGINT(2) O:\atcctest\ClearCase-Argv>perl -MIPC::Open3 -e open3($i,$o,0,qw(clear +tool));binmode $o, q(:bytes);print $i qq(chevent -rep README\n);$a=<$ +o>;print $i qq(.\n);chomp($a);$a=~s/\r\n?$//;print qq($a\n);print $i +qq(exit\n)" Terminating on signal SIGINT(2) O:\atcctest\ClearCase-Argv>perl -MIPC::Open3 -e open3($i,$o,0,qw(clear +tool));binmode $o, q(:unix);print $i qq(chevent -rep README\n);$a=<$o>;print $i qq(.\ +n);chomp($a);$a=~s/\r\n?$//;print qq($a\n);print $i qq(exit\n)" Terminating on signal SIGINT(2) O:\atcctest\ClearCase-Argv>perl -MIPC::Open3 -e open3($i,$o,0,qw(clear +tool));binmode $o, q(:unix crlf);print $i qq(chevent -rep README\n);$ +a=<$o>;print $i qq(.\n);chomp($a);$a=~s/\r\n?$//;print qq($a\n);print + $i qq(exit\n)" Terminating on signal SIGINT(2) O:\atcctest\ClearCase-Argv>perl -MIPC::Open3 -e open3($i,$o,0,qw(clear +tool));binmode $o, q(:unix stdio);print $i qq(chevent -rep README\n); +$a=<$o>;print $i qq(.\n);chomp($a);$a=~s/\r\n?$//;print qq($a\n);print $i qq(exit\n)"
Do I miss something obvious?
Non obvious?
Thanks,
Marc

Replies are listed 'Best First'.
Re: IPC::Open3: differences among replies of a background process
by diotalevi (Canon) on Dec 14, 2008 at 06:05 UTC

    It might be about Window's non-POSIX primary interface. Maybe the interactive commands are using some APIs that IPC::Open3 isn't going to be able to cope with. You might want to consult MSDN. Maybe there's something like strace but for Windows.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re: IPC::Open3: differences among replies of a background process
by zentara (Archbishop) on Dec 14, 2008 at 14:45 UTC
      Hi, Thanks for your reply, but so far, I don't do any non-blocking read: as long as I can handle stdout and stderr together, I can do blocking reads.

      I am afraid the other reply I got, from diotalevi, is correct: cleartool gets the user comments from an other device than stdin, and sends the prompt there as well.

      I tried to eliminate the other options (e.g. that the prompt would have been there, but with a carriage return hiding it, or that it would have been buffered and non flushed).

      I may have alternative strategies. Otherwise, I'll have to dig in the other APIs... OLE, and something called CAL.

      Thanks anyway,
      Marc

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://730212]
Approved by tye
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-24 18:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found