0

I want to start a C program in the background from the terminal. The program acts as bluetooth-driver, which means it has to stay open while the system is running. I tried with nohup and start-stop-daemon, but in both cases the c program gets the exit command and closes.

How can I start a C program from a terminal that then runs in the background? I want to start it and then be able to close the terminal on the gui (while the started c-programm keeps happily running).

Thanks!

4

Sounds like the program needs a controlling terminal to run (you can find out with strace if you don't have the source code).

You can provide the program with a controlling terminal (even when starting it as part of the system boot) by running it through screen (ot tmux).

screen cmd arg1 arg2
0

I think to fully daemonize a program, you would do

nohup the_command args ... </dev/null >/dev/null 2>/dev/null &
disown

Depending on your system, you should consider starting it at system startup using upstart or init or something like that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.