how to detect broken pipe ?

From: funtoosh (a_gilotra_at_yahoo.com)
Date: 12/20/03

  • Next message: Hale: "h2xs"
    Date: 19 Dec 2003 22:11:38 -0800
    
    

    Hi

    Scenario:

    I have a shell script e.g. a.bash
    This script wraps a program called "generate" like this:

    generate > /tmp/y.txt 2>&1 # both stdout and stderr r redirected to
    y.txt

    Now , I have perl script e.g. myPerl.pl and I modify a.bash such that:

    generate | perl myPerl.pl # pipe output from "generate" to the perl
    script.

    And in myPerl.pl, I wrote this :

    sub whatSignal { print "caught ",shift, "\n" };
    $SIG($_}=\ &whatSignal for keys %SIG

    And now I run a.bash in one xterm:
    Following happens:
    When press ctrl-C, it is caught.

    But when I kill pid of program "generate" from a different xterm, my
    script doesnt detect "broken pipe" ?

    Comments ?


  • Next message: Hale: "h2xs"

    Relevant Pages

    • Problem using Xterm in Expect script
      ... I have written a script which will spawn an xterm and executes the ... got to rwc test ...
      (comp.lang.tcl)
    • Background processes from a script
      ... I have a script that starts a background process - an X-enabled application ... I'll use xterm as a sample application (the real one is different but the ... echo Sleeping for 60 seconds ... they have elapsed and the script exits, ...
      (comp.unix.shell)
    • Re: Debugging gvim :!cmd with bash
      ... > I've simplified the problem to a trivial script. ... If I invoke it from an xterm command line, ... If that's true for bash, ...
      (comp.unix.shell)
    • Re: How to spawn a session in new window using expect?
      ... xterm open its own pseudo-terminal for the -e command to run ... Thus expect as no control and no idea about what's happening inside the ... You could run another expect script for the -e command. ...
      (comp.security.ssh)
    • Re: Background processes from a script
      ... > - interacts with that application and then exits. ... > X-application to be killed when the script exits or if the script is killed ... > I'll use xterm as a sample application (the real one is different but the ... > echo Sleeping for 60 seconds ...
      (comp.unix.shell)