open pipe vs signals causing problems ?

F

funtoosh

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
 
B

Brian McCauley

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\\
 
F

funtoosh

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 said:
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.
 
B

Brian McCauley

(e-mail address removed) (funtoosh) spits TOFU in my face:

[ TOFU is rude. Please don't do it. TOFU corrected ]
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 ?

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\\
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top