Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > writing to a pipe on win32

Reply
Thread Tools

writing to a pipe on win32

 
 
momena
Guest
Posts: n/a
 
      07-26-2004
Hi experts,
I need to write a perl script that will be called from a series of
executables chained thru pipes that read from STDIN and writes to
STDOUT. The following code works fine under regular circumstance. But
when there is a error down the pipe in one of the executables, the
pipe closes and then this script just exits. It does not print line
14. The troublesome line is line number 17. If I comment it out, the
script completes. From my very little perl knowledge, I was thinking
that in line 17, when we call "print $_" and the pipe broke due to the
error in another executable, it would generate SIGPIPE, but I get no
signal. Does SIGPIPE work on windows ?

1 sub signalhandler
2 {
3 print STDERR "*Received a SIG$_[0]\n";
4 }

5 my $Tmp_File = "c:/test_dir/testFile";

6 open(IN_FILE, ">$Tmp_File") || die "Open file error: $!";
7 binmode (IN_FILE);

8 while (<STDIN>) {
9 print IN_FILE ;
10 }
11 close(IN_FILE);

12 use sigtrap qw{handler signalhandler normal-signals
error-signals};

13 open(OUT_FILE, "$some_other_executable $Tmp_File |") || die
"Fork error: $!";
14 print STDERR "Opened file OUT_FILE!!\n";
15 binmode (OUT_FILE);
16 while (<OUT_FILE>) {
17 print $_;
18 }
19 unlink ($Tmp_File) || die "Remove file error: $!";

Thanks in advance.

Momena
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[named pipe] i wanna know about validate of pipe handle of client lee, wonsun C++ 1 11-02-2004 04:29 AM
writing to a pipe on win32 momena Perl 1 07-28-2004 01:30 AM
Why does IO::Pipe::END generate an EXCEPT pipe message? lvirden@gmail.com Perl Misc 1 06-02-2004 02:17 PM
[ANN] win32-pipe 0.0.1 Daniel Berger Ruby 0 11-22-2003 07:19 AM
named pipe problem on Win32 Daniel Berger Ruby 1 11-22-2003 01:48 AM



Advertisments