What is the difference of 'exec cmd &' and 'cmd &' in bash scripting?

What is the difference between the following fork statements ?

  1. command &
  2. exec command &

You can use wait $! for both statements. In my test I have found no difference in the behavior - but maybe I'm missing something.

Answers


The & overrides the exec since you can't both replace the existing process with a new process and run the new process in the background.


Need Your Help