Re: transfering signals to a subshell

From: Uwe Mayer (merkosh_at_hadiko.de)
Date: 08/16/03

  • Next message: Juergen Heck: "Re: Select files by date and move them"
    Date: Sat, 16 Aug 2003 11:53:24 +0200
    
    

    scriptOmatic wrote:

    [...]
     
    > If you are at the command line and enter the command above,
    > and then hit CTRL-C it should be sent to both
    > makeBackup and to mail

    Sorry, I should have been more clear. Here some "one-liners" that don't do
    as I expect:

    --test1--
    #!/bin/bash
    trap 'echo "test1"' 2 3
    ./test2 | ./test3
    sleep 5
    trap 2 3
    --eof--

    --test2--
    #!/bin/bash
    trap 'echo "test2"' 2 3
    echo "Some Text to output"
    sleep 5
    trap 2 3
    --eof--

    --test3--
    #!/bin/bash
    trap 'echo "test3"' 2 3
    echo "And some additional text"
    sleep 5
    trap 2 3
    --eof--

    Now I run test1 and press ^C immediately:
    $ ./test1
    And some additional text
    ^C
    test3
    test1

    The cursor does not return to the normal prompt immediately, instead I have
    to press ^C twice:

    $ ./test1
    And some additional text
    ^C
    test3
    test1
    ^C
    test1
    $

    Its clear that the output from test2 does not get printed, because it is
    piped to test3 and left there, however just as in my script: test2 does not
    execute its trap routine.
    And why do I have to press ^C twice?

    [...]

    > It's not clear to me why your script (which you did not post) does not
    > work.

    I hope the above is enough. The Script is rather long.

    > Uwe, here is a suggestion:
    > see the file file working.zip
    > at the archive below (and also new.zip if you like). These are all
    > written in shell (sh and/or ksh) and show some detailed useage of
    > traps and passsing signals from one shell to another. They are designed
    > do all work togethere. HTH !

    Thanks - I've had a look at "working" and noticed some nice possibilities,
    ie. the user-signals.

    Ciao
    Uwe

    -- 
         
    

  • Next message: Juergen Heck: "Re: Select files by date and move them"