Reputation: 495
I'm creating the following .bash_profile (from linuxfromscratch guide) for lfs user:
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
When executing su - lfs
I get:
[1]+ Stopped su - lfs
Executing fg
resumes lfs' user shell. Why is this happening?
Upvotes: 1
Views: 469
Reputation: 3461
That's because exec
executes the code in the current process. Normally a command is executed in a child shell/environment. Try the following:
$ bash # open second shell
$ exec false # close second shell
$ echo $? # get exit code
$ exit # close terminal
The man page isn't really helpful here. I often use exec
if I run a script through a Qt process and it should end after some period of time, regardless whether the command if finished or not.
Upvotes: 0