Hi,
Commands ps -A include four parameters are PID, TTY, TIME and CMD. I can not found pathnames of TTY and TIME which I can read from file in C language to get information display on screen. Thank you!
Ex:
PID TTY TIME CMD
1 ? 00:00:01 init
Do you mean the /proc directories? /proc/pid, from your example /proc/1
is the path.
However TIME comes from /var/adm/utmpx - you will have to use a structure defined in utmpx.h to read the file.
example code here:
loginacct/utmpx_login.c (from "The Linux Programming Interface")
As to the TTY, what are you trying to do?
/proc/pid/fd/0 is the tty for the process, if one exists. A ? in ps -A output means the process does not have a controlling terminal.
Thank you, but I see /proc/pid/fd/0 a socket, I cannot read it by C language cause I need read "TTY" to display the screen.