Running a process (job) in background.
I know how to run a job in the background, but when I type the 'bg' command, and then 'jobs', it still says the process is stopped. What do I need to do, probably to my program, to keep in running in the background?
Try "nohup command &"
The OSLib | Personal Site/Blog | /Dev/Nulled Hosting | WoW Linux Petition | The Wildcard - My IRC Network
If your application is mainly intended to be run in the background, it might be a good idea to do this from code instead of from the shell. The following piece of code will fork the process to break it loose from the terminal that started it, and effectively run it even more in the background than running it with 'bg' would, since killing the shell won't kill the process:
Of course, if you don't usually want to run your program in the background, or if you want to use your shell's job control, then this isn't a very good solution.
#include <unistd.h>int main(){ /* fork the process, kill the parent */ if(fork()) return 0; /* do stuff here; the process is now free of the terminal that started it */ return 0;}
Of course, if you don't usually want to run your program in the background, or if you want to use your shell's job control, then this isn't a very good solution.
Have you tried to use the set -b feature to see when your apps is stopped.
May be it's trying to read from ( write to ) the terminal.[ from the bash Info ] Background processes which attempt to read from (write to) the terminal are sent a `SIGTTIN'(`SIGTTOU') signal by the terminal driver, which, unless caught,suspends the process.
So what about trying to do some signal handlings inside your app.
May be it's trying to read from ( write to ) the terminal.[ from the bash Info ] Background processes which attempt to read from (write to) the terminal are sent a `SIGTTIN'(`SIGTTOU') signal by the terminal driver, which, unless caught,suspends the process.
So what about trying to do some signal handlings inside your app.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement