1

I have a node.js app located at /foo/bar/app.js
If I start it the like this:

cd /foo/bar
node app.js

lets say it was given PID 555 is it possible to find the absolute path /foo/bar/app.js of the app it's running? If I run ps 555 it will only tell me app.js because that's the argument that was passed to node. Is there any way to find out the full path of that node process?

UPDATE

I guess I should also point out that I'm not trying to get the path of the current app. It's a separate node app that is trying to find this info. Which may or may not be in the same directory. I'm guessing I'll need to use unix commands through node's Child Process module.

tyler mackenzie
  • 622
  • 7
  • 18
  • Consider [`process.env.PWD`](https://stackoverflow.com/questions/31414852/process-env-pwd-vs-process-cwd). – rishat Dec 09 '17 at 20:20
  • 1
    If you don't control that Node program and want to figure out where it is located, consider [`pwdx`](https://unix.stackexchange.com/a/94359/177879). – rishat Dec 09 '17 at 20:22
  • @RishatMuhametshin `pwdx` did it! If you post it as an answer I'll accept it. – tyler mackenzie Dec 09 '17 at 20:32

1 Answers1

4

Try using pwdx PID https://linux.die.net/man/1/pwdx

It should give you the working directory of the process.

Shawn Northrop
  • 5,826
  • 6
  • 42
  • 80