Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 27, 2013, 03:12 PM   #1
rmger
macrumors newbie
 
Join Date: Jan 2013
Alternative to the /proc

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?
rmger is offline   0 Reply With Quote
Old Jan 27, 2013, 03:48 PM   #2
Madd the Sane
macrumors 6502
 
Join Date: Nov 2010
Location: Utah
Try Activity Monitor. Usually the first opened object is its currently working directory.

Programmatically, I have no clue. Sorry
Madd the Sane is offline   0 Reply With Quote
Old Jan 27, 2013, 04:02 PM   #3
willieva
macrumors 6502
 
Join Date: Mar 2010
man ps
willieva is offline   0 Reply With Quote
Old Jan 27, 2013, 04:15 PM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
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/M.../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.
chown33 is offline   0 Reply With Quote
Old Jan 27, 2013, 04:35 PM   #5
rmger
Thread Starter
macrumors newbie
 
Join Date: Jan 2013
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.
rmger is offline   0 Reply With Quote
Old Jan 27, 2013, 04:49 PM   #6
Madd the Sane
macrumors 6502
 
Join Date: Nov 2010
Location: Utah
Quote:
Originally Posted by rmger View Post
"strings /proc/PID/environ -will show us variable environments of process." -I think that in OS X there is no such.
atMonitor does display that info, so there is a way.

Last edited by Madd the Sane; Jan 27, 2013 at 04:51 PM. Reason: It is called atMonitor
Madd the Sane is offline   0 Reply With Quote
Old Jan 27, 2013, 05:47 PM   #7
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by rmger View Post
"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
chown33 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
4,1 Proc Board vs 5,1 visual differences? iamMacPerson Mac Pro 5 Mar 23, 2014 10:44 PM
What Macbookpro should I go. Proc/Ram Flowiee MacBook Pro 1 May 16, 2013 08:08 AM
Running Single Proc on dual board 5,1 GXPvince Mac Pro 3 Apr 17, 2013 10:42 PM
What's the best Evernote Alternative?? Evev12 iPhone and iPod touch Apps 2 Mar 26, 2013 06:35 AM
Faulty new iMac? What's the replacement proc. oililymad iMac 2 Feb 11, 2013 12:16 AM

Forum Jump

All times are GMT -5. The time now is 04:14 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC