Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > open pipe vs signals causing problems ?

Reply
Thread Tools

open pipe vs signals causing problems ?

 
 
funtoosh
Guest
Posts: n/a
 
      02-13-2004
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
 
Reply With Quote
 
 
 
 
Brian McCauley
Guest
Posts: n/a
 
      02-13-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (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\\
 
Reply With Quote
 
 
 
 
funtoosh
Guest
Posts: n/a
 
      02-15-2004
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 <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> (E-Mail Removed) (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.

 
Reply With Quote
 
Brian McCauley
Guest
Posts: n/a
 
      02-17-2004
(E-Mail Removed) (funtoosh) spits TOFU in my face:

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

> Brian McCauley <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> > (E-Mail Removed) (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\\
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 8.26 Why doesn't open() return an error when a pipe open fails? PerlFAQ Server Perl Misc 0 04-28-2011 10:00 AM
[named pipe] i wanna know about validate of pipe handle of client lee, wonsun C++ 1 11-02-2004 04:29 AM
Why does IO::Pipe::END generate an EXCEPT pipe message? lvirden@gmail.com Perl Misc 1 06-02-2004 02:17 PM
control-c and threads, signals in 2.3 causing all sorts of issues Srikanth Mandava Python 1 02-19-2004 12:41 PM
open pipe vs signals causing problems ? funtoosh Perl Misc 4 02-17-2004 06:37 PM



Advertisments