Here is the code that is running on OpenBSD 4.2
#!/usr/local/bin/ruby
threads=[]
4.times do |i|
threads[i]=Thread.new do
%x{/usr/libexec/getty std.19200 tty00}
end
end
threads.each{|thr| thr.join}
I run it as a unix background job, I get the following
-bash-3.2$ ./whore.rb &
[1] 11801
-bash-3.2$ ps waux | grep djdoboy
djdoboy 15158 0.0 0.3 844 1540 pi Ss 9:41PM 0:00.05 -
bash
(bash)
djdoboy 11801 0.0 0.4 996 1872 pi S 10:03PM 0:00.01
/usr/local/bin/ruby ./whore.rb
djdoboy 4493 0.0 0.1 372 556 pi S 10:03PM 0:00.02
/usr/libexec/getty std.19200 tty00
djdoboy 19020 0.0 0.1 332 556 pi S 10:03PM 0:00.01
/usr/libexec/getty std.19200 tty00
djdoboy 456 0.0 0.1 364 564 pi S 10:03PM 0:00.02
/usr/libexec/getty std.19200 tty00
djdoboy 11853 0.0 0.1 260 584 pi S 10:03PM 0:00.01
/usr/libexec/getty std.19200 tty00
djdoboy 23871 0.0 0.1 532 408 pi R+ 10:03PM 0:00.00 ps
-waux
djdoboy 27426 0.0 0.1 220 524 pi S+ 10:03PM 0:00.00 grep
djdoboy
Now I get and relogin
-bash-3.2$ exit
logout
Connection closed by foreign host.
[cdalten@localhost ~]$ telnet
-bash-3.2$ ps waux | grep djdoboy
djdoboy 6724 0.0 0.3 1012 1548 p6 Ss 10:04PM 0:00.02 -
bash
(bash)
djdoboy 25303 0.0 0.1 576 448 p6 R+ 10:04PM 0:00.00 ps
-waux
djdoboy 8516 0.0 0.1 1012 408 p6 R+ 10:04PM 0:00.00 grep
djdoboy (bash)
djdoboy 11801 0.0 0.4 996 1872 pi- S 10:03PM 0:00.01
/usr/local/bin/ruby ./whore.rb
djdoboy 11853 0.0 0.1 260 584 pi- I 10:03PM 0:00.01
/usr/libexec/getty std.19200 tty00
djdoboy 456 0.0 0.1 364 564 pi- I 10:03PM 0:00.02
/usr/libexec/getty std.19200 tty00
djdoboy 4493 0.0 0.1 372 556 pi- I 10:03PM 0:00.02
/usr/libexec/getty std.19200 tty00
djdoboy 19020 0.0 0.1 332 556 pi- I 10:03PM 0:00.01
/usr/libexec/getty std.19200 tty00
And the threads are still there. How come ruby threads don’t get
killed
on exit? And more to the point, how do I kill them on exit?
Chad