|
Home > Archive > Unix Programming > September 2007 > Something funky is going the 'ps' program
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Something funky is going the 'ps' program
|
|
| K-mart Cashier 2007-09-09, 1:30 pm |
| I tried asking the following question on the ruby forum, but I was
told the issue I was having was an OS issue, not a ruby issue.
When I create 4 different threads of party (ie chat line program)
#!/usr/local/bin/ruby
threads=[]
4.times do |i|
threads[i]=Thread.new do
%x{/usr/local/bin/party}
end
end
threads.each{|thr| thr.join}
I just see the following on ps.
cdalten 25600 0.0 0.3 984 1552 px Is+ 8:51AM 0:00.04 -
bash (bash)
cdalten 14220 0.0 0.4 1168 1904 px T 8:59AM 0:00.02 /usr/
local/bin/ruby ./whore.rb
However, when I change "/usr/local/bin/party" to "/usr/libexec/getty
std.19200 tty01"
#!/usr/local/bin/ruby
threads=[]
4.times do |i|
threads[i]=Thread.new do
%x{/usr/libexec/getty std.19200 tty01}
end
end
threads.each{|thr| thr.join}
And run ps...
cdalten 10435 0.0 0.3 964 1576 pk Ss 9:14AM 0:00.07 -bash
(bash)
cdalten 17270 0.0 0.4 1072 1840 pk S 9:37AM 0:00.01 /usr/
local/bin/ruby ./whore.rb
cdalten 1657 0.0 0.1 340 552 pk S 9:37AM 0:00.00 /usr/
libexec/getty std.19200 tty01
cdalten 10456 0.0 0.1 244 544 pk S 9:37AM 0:00.00 /usr/
libexec/getty std.19200 tty01
cdalten 5657 0.0 0.1 248 552 pk S 9:37AM 0:00.00 /usr/
libexec/getty std.19200 tty01
cdalten 32352 0.0 0.1 264 556 pk S 9:37AM 0:00.00 /usr/
libexec/getty std.19200 tty01
cdalten 7489 0.0 0.1 648 380 pk R+ 9:37AM 0:00.00 ps -
waux
All four threads show on the list. Why would the threads show up in
one case and not the other?
| |
| Ulrich Eckhardt 2007-09-09, 7:35 pm |
| K-mart Cashier wrote:
> When I create 4 different threads of party (ie chat line program)
> #!/usr/local/bin/ruby
>
> threads=[]
>
> 4.times do |i|
> threads[i]=Thread.new do
> %x{/usr/local/bin/party}
> end
> end
>
> threads.each{|thr| thr.join}
>
> I just see the following on ps.
> cdalten 25600 0.0 0.3 984 1552 px Is+ 8:51AM 0:00.04 -
> bash (bash)
> cdalten 14220 0.0 0.4 1168 1904 px T 8:59AM 0:00.02 /usr/
> local/bin/ruby ./whore.rb
>
>
> However, when I change "/usr/local/bin/party" to "/usr/libexec/getty
> std.19200 tty01"
>
> #!/usr/local/bin/ruby
>
> threads=[]
>
> 4.times do |i|
> threads[i]=Thread.new do
> %x{/usr/libexec/getty std.19200 tty01}
> end
> end
>
> threads.each{|thr| thr.join}
>
> And run ps...
>
> cdalten 10435 0.0 0.3 964 1576 pk Ss 9:14AM 0:00.07 -bash
> (bash)
> cdalten 17270 0.0 0.4 1072 1840 pk S 9:37AM 0:00.01 /usr/
> local/bin/ruby ./whore.rb
> cdalten 1657 0.0 0.1 340 552 pk S 9:37AM 0:00.00 /usr/
> libexec/getty std.19200 tty01
> cdalten 10456 0.0 0.1 244 544 pk S 9:37AM 0:00.00 /usr/
> libexec/getty std.19200 tty01
Firstly, those are not threads but processes, 'ps' displays processes. I
don't know Ruby, so it's hard for me to guess what your script does, but my
guess is that you are simply starting threads that only start processes.
Now, I guess the difference between the two programs is that 'getty' is
designed to work on its own, while 'party' is killed when its parent
process terminates. You could try to debug the 'party' process (using gdb)
and see why it gets terminated.
Uli
| |
| K-mart Cashier 2007-09-10, 1:29 am |
| On Sep 9, 1:15 pm, Ulrich Eckhardt <dooms...@knuut.de> wrote:
> K-mart Cashier wrote:
>
>
>
>
>
>
>
>
>
>
>
>
> Firstly, those are not threads but processes, 'ps' displays processes. I
> don't know Ruby, so it's hard for me to guess what your script does, but my
> guess is that you are simply starting threads that only start processes.
>
> Now, I guess the difference between the two programs is that 'getty' is
> designed to work on its own, while 'party' is killed when its parent
> process terminates. You could try to debug the 'party' process (using gdb)
> and see why it gets terminated.
>
> Uli
When I run
#!/usr/local/bin/ruby
threads=[]
5.times do |i|
threads[i]=Thread.new do
%x{/usr/local/bin/party}
end
end
threads.each{|thr| thr.join}
I see the following:
-bash-3.2$ ./whore.rb &
[1] 2382
-bash-3.2$ Welcome to PARTY! Type '?' for help:
Welcome to PARTY! Type '?' for help:
Welcome to PARTY! Type '?' for help:
Welcome to PARTY! Type '?' for help:
And then it will just hang here for like 4 hours (as opposed to me
having me log out after 20 minutes).
| |
| K-mart Cashier 2007-09-10, 1:29 am |
| On Sep 9, 1:15 pm, Ulrich Eckhardt <dooms...@knuut.de> wrote:
> K-mart Cashier wrote:
>
>
>
>
>
>
>
>
>
>
>
>
> Firstly, those are not threads but processes, 'ps' displays processes. I
> don't know Ruby, so it's hard for me to guess what your script does, but my
> guess is that you are simply starting threads that only start processes.
>
> Now, I guess the difference between the two programs is that 'getty' is
> designed to work on its own, while 'party' is killed when its parent
> process terminates. You could try to debug the 'party' process (using gdb)
> and see why it gets terminated.
>
> Uli
sometimes I will see
cdalten 7257 13309 7257 d6bd1c30 0 Is+ pi 0:00.03 -bash
(bash)
cdalten 21415 7257 21415 d6bd1c30 1 T pi 0:00.01 /usr/
local/bin/ruby
cdalten 24944 7257 24944 d6bd1c30 1 I pi 0:00.02 /usr/
local/bin/ruby
cdalten 29653 7257 29653 d6bd1c30 1 I pi 0:00.02 /usr/
local/bin/ruby
cdalten 17222 7257 17222 d6bd1c30 1 I pi 0:00.02 /usr/
local/bin/ruby
cdalten 11968 15356 11968 e978d934 0 Is px 0:00.06 -bash
(bash)
cdalten 32536 11968 32536 e978d934 1 R+ px 0:00.00 ps -j
And other times, I will see
sometimes I will see
cdalten 7257 13309 7257 d6bd1c30 0 Is+ pi 0:00.03 -bash
(bash)
cdalten 21415 7257 21415 d6bd1c30 1 T pi 0:00.01 /usr/
local/bin/party
cdalten 24944 7257 24944 d6bd1c30 1 S pi 0:00.02 /usr/
local/bin/party
cdalten 29653 7257 29653 d6bd1c30 1 S pi 0:00.02 /usr/
local/bin/party
cdalten 17222 7257 17222 d6bd1c30 1 S pi 0:00.02 /usr/local/
bin/party
cdalten 11968 15356 11968 e978d934 0 Is px 0:00.06 -bash
(bash)
cdalten 32536 11968 32536 e978d934 1 R+ px 0:00.00 ps -j
| |
| Scott Lurndal 2007-09-10, 7:16 pm |
| K-mart Cashier <cdalten@gmail.com> writes:
>sometimes I will see
>cdalten 7257 13309 7257 d6bd1c30 0 Is+ pi 0:00.03 -bash
>(bash)
>cdalten 21415 7257 21415 d6bd1c30 1 T pi 0:00.01 /usr/
>local/bin/ruby
>cdalten 24944 7257 24944 d6bd1c30 1 I pi 0:00.02 /usr/
>local/bin/ruby
>cdalten 29653 7257 29653 d6bd1c30 1 I pi 0:00.02 /usr/
>local/bin/ruby
>cdalten 17222 7257 17222 d6bd1c30 1 I pi 0:00.02 /usr/
>local/bin/ruby
>cdalten 11968 15356 11968 e978d934 0 Is px 0:00.06 -bash
>(bash)
>cdalten 32536 11968 32536 e978d934 1 R+ px 0:00.00 ps -j
>
>And other times, I will see
>sometimes I will see
>cdalten 7257 13309 7257 d6bd1c30 0 Is+ pi 0:00.03 -bash
>(bash)
>cdalten 21415 7257 21415 d6bd1c30 1 T pi 0:00.01 /usr/
>local/bin/party
>cdalten 24944 7257 24944 d6bd1c30 1 S pi 0:00.02 /usr/
>local/bin/party
>cdalten 29653 7257 29653 d6bd1c30 1 S pi 0:00.02 /usr/
>local/bin/party
>cdalten 17222 7257 17222 d6bd1c30 1 S pi 0:00.02 /usr/local/
>bin/party
>cdalten 11968 15356 11968 e978d934 0 Is px 0:00.06 -bash
>(bash)
>cdalten 32536 11968 32536 e978d934 1 R+ px 0:00.00 ps -j
>
How do you manage to get the exact same PID values?
scott
|
|
|
|
|