Given the following C program:
int main() {
do_something();
if (console_command_m_got) {
do_something_else_1();
}
if (console_command_q_got) {
exit();
}
return 0;
}
When I start a C program in the terminal, it runs there. I am looking for a way to start the program from the terminal, but detach it from that terminal. It should not close, when I close the console and run in the background like when I put it in the autostart.
Is there any possibility, to change the control flow of that running program by entering commands in the console? A little example of how I could imagine the workflow:
$ ./run_program // Program starts and runs in background
$ ./run_program -m // Modify the behaviour of the running program (if-statement above)
$ ./run_program -q // Stop the running program
Or maybe, I have a complete wrong approach.