Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

rmger

macrumors member
Original poster
Jan 26, 2013
34
0
I know that "proc" absent in OS X, but can you show an alternative?

Examples:
strings /proc/PID/environ -will show us variable environments of process.
file /proc/PID/cwd -will show us working catalog of process.
stat -c %z /proc/PID -will show us when the process is started.
cat /proc/PID/status -will show us who is the owner of this process and more.

Possibly in OS X too there is such place where it is possible to learn a lot of things about process?
 

Madd the Sane

macrumors 6502a
Nov 8, 2010
534
73
Utah
Try Activity Monitor. Usually the first opened object is its currently working directory.

Programmatically, I have no clue. Sorry
 

chown33

Moderator
Staff member
Aug 9, 2009
10,679
8,303
A sea of green
Using what language?

The posted examples are shell commands. So do you need shell commands? If so, then the 'man ps' suggestion is a good one. Also see 'man top'.

The sysctl(3) C function is a way to get varied process info using C:
http://developer.apple.com/library/Mac/#documentation/Darwin/Reference/ManPages/man3/sysctl.3.html

See the KERN_PROC selector, and also find the search term "kproc" on the man page for an example. You'll need to know the struct def, so refer to the appropriate .h file.

Finally, the source for the commands 'ps' and 'top' is available from the Darwin project:
http://www.opensource.apple.com/
Both programs run setuid-root, so you will need enhanced privileges to obtain some process info. There's an API for that.
 

rmger

macrumors member
Original poster
Jan 26, 2013
34
0
Thanks for answers.
With the 'ps' and 'top' I will only decide this tasks (already decided):

"file /proc/PID/cwd -will show us working catalog of process.
stat -c %z /proc/PID -will show us when the process is started.
cat /proc/PID/status -will show us who is the owner of this process"

chown33, with shell commands.

"strings /proc/PID/environ -will show us variable environments of process." -I think that in OS X there is no such.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,679
8,303
A sea of green
"strings /proc/PID/environ -will show us variable environments of process." -I think that in OS X there is no such.

See the man page for 'ps':
-E Display the environment as well. This does not reflect changes in the environment after process launch.
At the Terminal window, 'ps' is aware of the window width (see its man page). So either use the -w option (repeated, per its man page), or try this:
Code:
ps -E | cat
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.