For example, system("sh /mydir/some-script.sh &")
system("sh /mydir/some-script.sh &")
executes
/bin/sh -c 'sh /mydir/some-script.sh &'
system
will return as soon as outer shell returns, which will be immediately after it launches the inner shell. Neither shell will wait for some-script.sh
to finish.
$ cat some-script.sh
sleep 1
echo foo
$ /bin/sh -c 'sh some-script.sh &' ; echo bar ; sleep 2
bar
foo