Re: Threads killen
Mauricio Fernández <[email protected]> Thu, 15 May 2003 10:58:06 +0200
| Newsgroups | gmane.comp.lang.ruby.german |
|---|---|
| Message-ID | <[email protected]> |
On Wed, May 14, 2003 at 05:39:03PM +0200, Markus Walser wrote:
> Hallo
> Attached ist ein kleines Beispiel, welches leider nicht so funktioniert wie ich
> mir das vorgestellt habe :-(
> Was im Buch "Programmieren mit Ruby" Seite 93 ueber Ruby Threads geschrieben
> steht, hat sich leider bewahrheitet: Der Prozess, welcher mit system gestartet wird,
> laeuft nach dem kill weiter. Selbst nach beenden des Ruby Skripts ist er noch aktiv.
>
> Kennt da jemand einen Workaround oder weiss jemand wie man das sauber machen
> muesste, damit der mit system gestartete Prozess durch den Aufruf von Thread.kill
> auch beendet wird?
matz hat gesprochen:
If you want to kill child processes when the thread is down,
th = Thread.new{
Thread.current[:children] = []
begin
... add child processes to Thread.current[:children]
ensure
Process.kill("TERM", *Thread.current[:children])
end
}
is the way to go.
matz.
--
_ _
| |__ __ _| |_ ___ _ __ ___ __ _ _ __
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com
I'm telling you that the kernel is stable not because it's a kernel,
but because I refuse to listen to arguments like this.
-- Linus Torvalds