views:

110

answers:

3

Actually, I would like to have some kind of progress bar. I would like for the user to be able to recognize when the process "hangs".

Usually I will use it to show the progress of ./configure and make calls.

ADDENDUM: I need progress that makes no use of external tools. (no bar)

/proc/pid/stat is ok, but doesn't solve the problem about possible child processes

+1  A: 

if you want a progress bar, check this out

ghostdog74
see ADDENDUM...
Marki
A: 

dialog has a progress bar.

As far as monitoring status (other than milestones in your code), you could probably parse /proc/PID/status or the output of ps.

Edit:

To get a list of child processes, parse the output of:

ps -ppid PID_OF_PARENT
Dennis Williamson
see ADDENDUM...
Marki
A: 

If you want a general solution, then you're going to have to do recursive ps -ppid ... calls---or do a single big ps call that gets everything at once and parse it yourself to get all the descendants of your desired parent process. (You could prune the stuff you need to pay attention to by first getting the session leader or process group of your parent process, and then just doing a ps for processes with that session leader/process group. If you're lucky, no more pruning will be needed.)

But if you're dealing with ./configure and make calls specifically, why don't you pipe their output to a temp file and just watch that to see it's getting longer, or when it was last touched, or so on?

profjim