Where Can I Find My (Current Shell Process') Pid?

I'm on OS X using ZSH (have lots of homebrew stuff, too).

I'd like to know the PID of my current terminal.

(I'm learning more about process management on *nix systems, pstree and the like, and so this is more an academic question vs. a specific use case I'm trying to solve)

EDIT: to clarify, I'm referring to the process that is running my current terminal/commandline.

2

1 Answer

The special variable $$ is the current pid of the shell you are running, for any Bourne compatible (and, so, POSIX) shell.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest