asker
asker

Reputation: 1

Get the initial working directory and executable name of a process?

Is there a way to securely get both the initial working directory and the executable name of a process? By "initial working directory", I mean the current working directory of the process when it is first spawned and executed, and by "secure" I mean that the process being inspected cannot alter the values as observed from outside that process's address space. The process ID of the process in question is known in advance.

http://www.lindevdoc.org/wiki//proc/PID/exe describes how to get the executable name of a process, but is this secure?

I have not found a way to securely get a process's initial (but not necessarily current) working directory. Is this possible without modifying the kernel?

Edit: The language is C and platform is Linux (I'm trying to implement this in a FUSE file system).

Upvotes: 0

Views: 361

Answers (1)

David Kierans
David Kierans

Reputation: 1599

On Linux type systems lsof is always useful. lsof -p

Upvotes: 0

Related Questions