Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > how to kill a process initiated by system()

Reply
Thread Tools

how to kill a process initiated by system()

 
 
Howard
Guest
Posts: n/a
 
      10-27-2004
Hi All,

I ran into a scenario that I initiate from system(), however, the
process doesn't exit and hang over there. I am just wondering if there
is a way to kill the process after half hour run no matter it is
healthy or not.

Regards,
 
Reply With Quote
 
 
 
 
Thomas Kratz
Guest
Posts: n/a
 
      10-27-2004
Howard wrote:

> Hi All,
>
> I ran into a scenario that I initiate from system(), however, the
> process doesn't exit and hang over there. I am just wondering if there
> is a way to kill the process after half hour run no matter it is
> healthy or not.
>
> Regards,


perldoc -f alarm

Thomas

--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e. r^.>l^..>k^.-
 
Reply With Quote
 
 
 
 
Anno Siegel
Guest
Posts: n/a
 
      10-27-2004
Howard <(E-Mail Removed)> wrote in comp.lang.perl.misc:
> Hi All,
>
> I ran into a scenario that I initiate from system(), however, the
> process doesn't exit and hang over there. I am just wondering if there
> is a way to kill the process after half hour run no matter it is
> healthy or not.


That will be hard to do, because system() only returns after the external
process has ended. You could set an alarm timer and kill the process
from the signal handler if you knew the pid, but you don't.

You'll be much better off creating the child process yourself, probably
using explicit fork. The parent process knows the pid and can kill
the child process when it runs too long.

Anno
 
Reply With Quote
 
Anno Siegel
Guest
Posts: n/a
 
      10-27-2004
Thomas Kratz <(E-Mail Removed)> wrote in comp.lang.perl.misc:
> Howard wrote:
>
> > Hi All,
> >
> > I ran into a scenario that I initiate from system(), however, the
> > process doesn't exit and hang over there. I am just wondering if there
> > is a way to kill the process after half hour run no matter it is
> > healthy or not.
> >
> > Regards,

>
> perldoc -f alarm


Fine if you know what pid to kill, but with system() you don't.

Anno
 
Reply With Quote
 
Thomas Kratz
Guest
Posts: n/a
 
      10-27-2004
Anno Siegel wrote:

> Thomas Kratz <(E-Mail Removed)> wrote in comp.lang.perl.misc:
>
>>Howard wrote:
>>
>>
>>>Hi All,
>>>
>>>I ran into a scenario that I initiate from system(), however, the
>>>process doesn't exit and hang over there. I am just wondering if there
>>>is a way to kill the process after half hour run no matter it is
>>>healthy or not.
>>>
>>>Regards,

>>
>>perldoc -f alarm

>
>
> Fine if you know what pid to kill, but with system() you don't.
>
> Anno


You're right. Foggy memory, I really should test before posting.
It's time to go home now

Thomas

--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e. r^.>l^..>k^.-
 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
outside initiated traffic to access internal network range through pix firewall with translation Wehay Cisco 3 03-20-2005 07:26 AM
KILL BABY KILL widescreen drsd2kill DVD Video 3 11-29-2004 09:36 PM
Bava's KILL BABY KILL widescreen drsd2kill DVD Video 0 11-27-2004 12:04 AM
PIX VPN tunnels - only works when traffic initiated from one side ? Brian Ipsen Cisco 10 02-25-2004 08:26 AM



Advertisments