Sto leggendo "BASH pocket guide of Oreilly".
Diceva:
L'ID processo del processo Bash corrente.
In alcuni casi, può essere diverso da $$.
Sopra la spiegazione, spiegato $BASHPID
variabile.
Domanda: quali casi?
Risposta accettata:
Un esempio è fornito nel BASHPID
descrizione della manpage di bash:
BASHPID
Expands to the process id of the current bash process. This
differs from $$ under certain circumstances, such as subshells
that do not require bash to be re-initialized.
Ecco un esempio di una subshell che restituisce il contenuto della variabile, insieme a $$
e il contenuto di BASHPID
al di fuori della subshell.
$ echo $(echo $BASHPID $$) $$ $BASHPID
25680 16920 16920 16920
# | | | |
# | | | -- $BASHPID outside of the subshell
# | | -- $$ outside of the subshell
# | -- $$ inside of the subshell
# -- $BASHPID inside of the subshell