how to kill a process initiated by system()

H

Howard

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,
 
T

Thomas Kratz

Howard said:
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^.-
 
A

Anno Siegel

Howard said:
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
 
T

Thomas Kratz

Anno said:
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^.-
 

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,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top