, , bash, PID, . , PID .
, bash exec.
. -, C, PID:
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
printf ("C process pid is %d\n", getpid());
return 0;
}
bash script, PID , exec:
#!/bin/bash
echo Bash process PID is $$
exec ./printpid > $$.log
a script, printpid.sh script :
#!/bin/bash
./printpid.sh
./printpid.sh
./printpid.sh
, :
$ ls
example.sh printpid printpid.c printpid.sh
$ ./example.sh
Bash process PID is 6397
Bash process PID is 6398
Bash process PID is 6399
$ ls
6397.log 6398.log 6399.log example.sh printpid printpid.c printpid.sh
$ cat 6397.log
C process pid is 6397
$ cat 6398.log
C process pid is 6398
$ cat 6399.log
C process pid is 6399
$
, exec, script - , bash , exec.
!
user405725