Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

A coworker ran into this issue twice and I don't know what's wrong. His ps command hangs, taking about 25% of the CPU.

   in_progress=1
   sleep 10

   while [ "$in_progress" -eq 1 ]; do
      num_isp=`ps -e | grep isputility | grep -v grep | wc -l`
      if [ "$num_isp" -eq 0 ]; then
         in_progress=0
      fi
      sleep 10
   done

Below is the output of the ps command that hung.

       F S   UID        PID       PPID  C PRI  NI ADDR    SZ WCHAN STIME TTY          TIME CMD
00100000 -     0   35672094    1204253  -  10   0    -  844K -     Apr16 ?        00:00:00 /bin/sh /home/customProgram
00100000 -     0   43548705   42545184  -  10   0    -  648K -     11:51 ?        00:00:00 ps –elf
00100000 -     0   41926696   35672094  -  10   0    -  648K -     Apr16 ?        03:53:01 ps -e
00100000 -     0   41926702   35672094  -  10   0    -  672K -     Apr16 ?        00:00:00 grep isputility
00100000 -     0   41926704   35672094  -  10   0    -  672K -     Apr16 ?        00:00:00 grep -v grep
00100000 -     0   41926706   35672094  -  10   0    -  640K -     Apr16 ?        00:00:00 wc -l

Running QNX hogs command (similar to top) shows ps is using ~25% of the CPU.

hogs -% 1 -n
PID             NAME  MSEC  PIDS SYSTEM
1            procnto  2116   71%    70%
41926696           ps   763   25%    25%

Can anyone point us in the right direction to figure out why ps hung and what we can do about it?

share|improve this question
2  
you might want to look at Why does my system hang when I run ps, w and possibly other commands? –  Anthon Apr 18 '13 at 20:19
    
those TTY=? outputs are suspicious, particularly since these look like commands that are clearly actually on a tty. It's possibly looping through something trying to find the tty and then giving up. –  Random832 Apr 19 '13 at 12:47

1 Answer 1

Try executing strace ps and see what system call it is hanging on and then take action accordingly.

share|improve this answer
2  
That would very likely help. I wish QNX had strace. –  kmort Apr 19 '13 at 12:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.