16.9k views
3 votes
Which variable contains current shell process id?

1) $*
2) $?
3) $$
4) Cannot be determined

User Captcoma
by
8.4k points

1 Answer

4 votes

Final answer:

The variable that contains the current shell process id is $$, which is the standard special variable in Unix-like shells for referring to the process ID of the running shell.

Step-by-step explanation:

The variable that contains the current shell process id is $$. In Unix-based operating systems and environments like Linux, when working within the shell, various special variables are used to hold specific data. The symbols $*, $?, and $$ are such variables, with each having a distinct meaning:

  • $* lists all the arguments passed to the script.
  • $? gives the exit status of the most recently run process.
  • $$ is used to refer to the process ID (pid) of the current shell.

Therefore, the correct answer to the question 'Which variable contains current shell process id?' is option 3) $$.

User Sebastian Lange
by
8.9k points