linuxshellinit.dstart-stop-daemon

start-stop-daemon with --background vs running using & option


What is the difference in running a process in background using start-stop-daemon with --background option and using with &?Which option is best and why?


Solution

  • If you use start-stop-daemon --background then start-stop-daemon will fork off a process to run in the background and then start-stop-daemon immediately exits. Among other things this means you can check the exit status of start-stop-daemon.

    If you use start-stop-daemon & then the shell forks off a background process and runs start-stop-daemon in it. You won't be able to check its exit status as it won't actually exit (until the thing it runs exits).

    In most cases start-stop-daemon --background is a better choice.