SyntaxFix
Write A Post
Hire A Developer
Questions
🔍
[bash] Why is $$ returning the same id as the parent process?
Home
Question
Why is $$ returning the same id as the parent process?
Parentheses invoke a
subshell in Bash
. Since it's only a subshell it might have the same PID - depends on implementation.
The C program you invoke is a separate process, which has its own unique PID - doesn't matter if it's in a subshell or not.
$$
is an alias in Bash to
the current script PID
. See
differences between
$$
and
$BASHPID
here
, and right above that the additional variable
$BASH_SUBSHELL
which contains the nesting level.
Examples related to
bash
•
Comparing a variable with a string python not working when redirecting from bash script
•
Zipping a file in bash fails
•
How do I prevent Conda from activating the base environment by default?
•
Get first line of a shell command's output
•
Fixing a systemd service 203/EXEC failure (no such file or directory)
•
/bin/sh: apt-get: not found
•
VSCode Change Default Terminal
•
Run bash command on jenkins pipeline
•
How to check if the docker engine and a docker container are running?
•
How to switch Python versions in Terminal?
Examples related to
shell
•
Comparing a variable with a string python not working when redirecting from bash script
•
Get first line of a shell command's output
•
How to run shell script file using nodejs?
•
Run bash command on jenkins pipeline
•
Way to create multiline comments in Bash?
•
How to do multiline shell script in Ansible
•
How to check if a file exists in a shell script
•
How to check if an environment variable exists and get its value?
•
Curl to return http status code along with the response
•
docker entrypoint running bash script gets "permission denied"
Examples related to
pid
•
How to get PID by process name?
•
Why is $$ returning the same id as the parent process?
•
How to get PID of process by specifying process name and store it in a variable to use further?
•
ERROR! MySQL manager or server PID file could not be found! QNAP
•
How to get the PID of a process by giving the process name in Mac OS X ?
•
Determine the process pid listening on a certain port
•
What is a .pid file and what does it contain?
•
How to get PID of process I've just started within java program?
•
How to check if a process id (PID) exists
•
How does a Linux/Unix Bash script know its own PID?
Examples related to
subshell
•
Why is $$ returning the same id as the parent process?