With the exec command, you can execute a process without forking a new process.
In the following screenshot a Korn shell (ksh) is started and is being replaced with a
bash shell using the exec command. The pid of the bash shell is the same as the pid
of the Korn shell. Exiting the child bash shell will get me back to the parent bash,
not to the Korn shell (which does not exist anymore).
[root@localhost ~]$ echo $$
4224 # PID of bash
[root@localhost ~]$ ksh
$ echo $$ $PPID
5343 4224 # PID of ksh and bash
$ exec bash
[root@localhost ~]$ echo $$ $PPID
5343 4224 # PID of bash and bash
[root@localhost ~]$ exit
exit
[root@localhost ~]$ echo $$
4224
In the following screenshot a Korn shell (ksh) is started and is being replaced with a
bash shell using the exec command. The pid of the bash shell is the same as the pid
of the Korn shell. Exiting the child bash shell will get me back to the parent bash,
not to the Korn shell (which does not exist anymore).
[root@localhost ~]$ echo $$
4224 # PID of bash
[root@localhost ~]$ ksh
$ echo $$ $PPID
5343 4224 # PID of ksh and bash
$ exec bash
[root@localhost ~]$ echo $$ $PPID
5343 4224 # PID of bash and bash
[root@localhost ~]$ exit
exit
[root@localhost ~]$ echo $$
4224