Process information

Gary D. Wong gar at cory.Berkeley.EDU
Tue Jul 4 11:18:45 AEST 1989


Hi there,

Can anyone tell me if there is a C system call to find the
user, process id and accumulated cpu time of all processes
currently running?

I have tried 'system("ps > temp_file")' but the system call never
returns, leaving my program waiting. The file is created.

I have also tried using the popen command to pipe the stdout of the ps
command to my program, reading with a fgets. After reading the data,
fgets does not encounter an eof condition, and just waits for addition
lines.

In both cases, the requested data is received but there is no termination
of the ps command. A shell is created with the appropriate command (sh -c ps)
which continues to use cpu time, and never exits. Not until that shell
is killed does the program continue.

Any insight to my error or a possible solution would be greatly appriciated, 

 Gary D. Wong  gar at cory.berkeley.edu  //   "It is better to remain silent   \\
 University of California, Berkeley   <<    and thought a fool, than to     >> 
 (415) 642-9304		              \\    open your mouth and confirm it" //
 Disclaimer: "Please, Colonel Hogan, I see NOTHING, I see NOOOTHINNNNNG!"



More information about the Comp.unix.questions mailing list