open pipe vs signals causing problems ?

Discussion in 'Perl' started by funtoosh, Feb 13, 2004.

  1. funtoosh

    funtoosh Guest

    Hi

    I am using latest PERL provided with REDHAT 9.

    I use this snippet of perl in t.pl

    $SIG{'TERM'}=\&doItNow ;
    $anotherProgram=$ARGV[0];

    open (AP,"$anotherProgram |") or die "$_ \n" ;

    sub doItNow {
    print "called doItNow \n ";
    }

    and I run it as follows at xterm prompt :
    perl t.pl "../working/nameoftheprogram" &

    So, I put it under background.

    Now I do ps at the same prompt and I see the process id of perl script
    and the anotherProgram.

    Now, when I send signal SIGTERM to the perl script, it DOES NOT call
    the installed handler

    kill -15 <process-id of the perl script>

    Any clue ?

    Sorry, for dumb question :( but this post is the only hope left to me.

    thx
    funtoosh, Feb 13, 2004
    #1
    1. Advertising

  2. (funtoosh) writes:

    > I am using latest PERL


    It's Perl not PERL.

    > provided with REDHAT 9.


    Perhaps it would help those of us who use SuSE or a different version
    of RedHat even some other *nix is you were to say what version of Perl
    that is since this is marginally more likely to be a Perl issue than
    an OS issue.

    At least show us the first line form "perl -v" and maybe even selected
    highlights of "perl -V" if you suspect this could be platform-related
    (and that wouldn't be a ureasonable supposition),

    > I use this snippet of perl in t.pl
    >
    > $SIG{'TERM'}=\&doItNow ;
    > $anotherProgram=$ARGV[0];
    >
    > open (AP,"$anotherProgram |") or die "$_ \n" ;
    >
    > sub doItNow {
    > print "called doItNow \n ";
    > }


    > perl t.pl "../working/nameoftheprogram" &


    > Now, when I send signal SIGTERM to the perl script, it DOES NOT call
    > the installed handler


    Your test script works OK for me on 5.6.1 and 5.8.0 on SuSE Linux
    (albeit with an old glibc).

    The newsgroup comp.lang.perl does not exist (see FAQ). Please do not
    start threads there.

    --
    \\ ( )
    . _\\__[oo
    .__/ \\ /\@
    . l___\\
    # ll l\\
    ###LL LL\\
    Brian McCauley, Feb 13, 2004
    #2
    1. Advertising

  3. funtoosh

    funtoosh Guest

    Yes. Its my fault. I shd. have provided more information abt the
    environment.
    I am using v5.6.1 of Perl on i386 linux. Kernel 2.4.20-20.9 from
    Redhat

    libc-2.2.5.so is installed on my system.

    So, when u run this script, it catches the signal and also kills
    anotherProgram too ?


    Brian McCauley <> wrote in message news:<>...
    > (funtoosh) writes:
    >
    > > I am using latest PERL

    >
    > It's Perl not PERL.
    >
    > > provided with REDHAT 9.

    >
    > Perhaps it would help those of us who use SuSE or a different version
    > of RedHat even some other *nix is you were to say what version of Perl
    > that is since this is marginally more likely to be a Perl issue than
    > an OS issue.
    >
    > At least show us the first line form "perl -v" and maybe even selected
    > highlights of "perl -V" if you suspect this could be platform-related
    > (and that wouldn't be a ureasonable supposition),
    >
    > > I use this snippet of perl in t.pl
    > >
    > > $SIG{'TERM'}=\&doItNow ;
    > > $anotherProgram=$ARGV[0];
    > >
    > > open (AP,"$anotherProgram |") or die "$_ \n" ;
    > >
    > > sub doItNow {
    > > print "called doItNow \n ";
    > > }

    >
    > > perl t.pl "../working/nameoftheprogram" &

    >
    > > Now, when I send signal SIGTERM to the perl script, it DOES NOT call
    > > the installed handler

    >
    > Your test script works OK for me on 5.6.1 and 5.8.0 on SuSE Linux
    > (albeit with an old glibc).
    >
    > The newsgroup comp.lang.perl does not exist (see FAQ). Please do not
    > start threads there.
    funtoosh, Feb 15, 2004
    #3
  4. (funtoosh) spits TOFU in my face:

    [ TOFU is rude. Please don't do it. TOFU corrected ]

    > Brian McCauley <> wrote in message news:<>...
    > > (funtoosh) writes:
    > >
    > > > I am using latest PERL provided with REDHAT 9.

    > >
    > > At least show us the first line form "perl -v" and maybe even selected
    > > highlights of "perl -V" if you suspect this could be platform-related
    > > (and that wouldn't be a ureasonable supposition),

    >
    > I am using v5.6.1 of Perl on i386 linux. Kernel 2.4.20-20.9 from
    > Redhat
    >
    > libc-2.2.5.so is installed on my system.


    > > > Now, when I send signal SIGTERM to the perl script, it DOES NOT call
    > > > the installed handler

    > >
    > > Your test script works OK for me on 5.6.1 and 5.8.0 on SuSE Linux
    > > (albeit with an old glibc).

    >
    > So, when u run this script, it catches the signal and also kills
    > anotherProgram too ?


    It catches the signal. There's nothing in the test script to
    explicitly kill the other program so I had no way of guessing this was
    part of the desired behaviour.

    Did you perhaps mean to send the SIGTERM to a process group rather
    than a single process?

    Under normal circumstances a child started with a '-|' mode open()
    will terminate on a SIGPIPE when the parent closes the FIFO.

    --
    \\ ( )
    . _\\__[oo
    .__/ \\ /\@
    . l___\\
    # ll l\\
    ###LL LL\\
    Brian McCauley, Feb 17, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. lee, wonsun
    Replies:
    1
    Views:
    485
    Jack Klein
    Nov 2, 2004
  2. Srikanth Mandava
    Replies:
    1
    Views:
    393
    Michael Hudson
    Feb 19, 2004
  3. funtoosh

    open pipe vs signals causing problems ?

    funtoosh, Feb 13, 2004, in forum: Perl Misc
    Replies:
    4
    Views:
    144
    Brian McCauley
    Feb 17, 2004
  4. Replies:
    1
    Views:
    222
    Ben Morrow
    Jun 2, 2004
  5. PerlFAQ Server
    Replies:
    0
    Views:
    324
    PerlFAQ Server
    Apr 28, 2011
Loading...

Share This Page