If I do:
sleep 1 versus
sleep 1 & wait $! will there be any difference in terms of CPU usage for spawning a foreground process versus a background process? Or will the performance of both lines be exactly equal?
With both commands, the shell will 1/ create a parallel subprocess which executes sleep, 2/tell the OS… put the shell process on pause until the sleep process ends. Then the performances are equal.
Yes.
On my system the first takes 3.0 ms and the second takes 3.3 ms CPU time.
In practice I would never worry about the 0.3 ms CPU time if you are sleeping a full second.
The 0.3 ms is probably caused by the extra fork that is needed to put sleep in the background. In other words: It is a one-time cost, not a 10% extra cost for running jobs in the background.