writing to a pipe on win32

From: momena (momenaa_at_yahoo.com)
Date: 07/23/04

  • Next message: Troy Knight: "declaring constants"
    Date: 23 Jul 2004 10:43:03 -0700
    
    

    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


  • Next message: Troy Knight: "declaring constants"

    Relevant Pages

    • writing to a pipe on win32
      ... I need to write a perl script that will be called from a series of ... when there is a error down the pipe in one of the executables, ... pipe closes and then this script just exits. ...
      (comp.lang.perl.misc)
    • Re: What is required for perl scripts to run correct when launched from rc scripts on HPUX 11?
      ... script is and the related terminology, ... The funny thing is I have another perl script that runs fine when run ... exit caused the other program on the front of the pipe to die. ...
      (comp.lang.perl.misc)
    • Re: Shell Commands (Getting PID and Timing Them)
      ... >> # Read from PIPE, have a cup of coffee, sleep ... assuming we have the shell script hello.sh: ... The Perl script will fork a child which exec's hello.sh and then reads ...
      (comp.lang.perl.misc)
    • Re: writing to a pipe on win32
      ... > when there is a error down the pipe in one of the executables, ... > pipe closes and then this script just exits. ... > 12 use sigtrap qw{handler signalhandler normal-signals ...
      (comp.lang.perl)
    • accessing a pipe from TCL and C, hang in `close/exit
      ... I have a TCL shell script which opens a socket to some remote host, ... and opens a read-converter pipe. ... data arrives on the remote host. ... Now I want to close the channel from C++: ...
      (comp.lang.tcl)