background process
How do I make my program run as a background process?
I am trying to make a web-server but I don't want it to show in the console. (I am programming in C) Thanx |
when you call the program, include an '&' at the end.
Code:
./myprog & |
Yes, but the '&' doesn't work on my program since I have made it myself =) .
|
the fact that you wrote it isn't the issue, all software was written by someone. if you start this program(s) at the prompt then the '&' will push it to the background.
|
wow
yes, it really runs in the background!!!
I was misled by the output from the program but now I see that it really runs as a background process. thank you very much! |
but surely there is a way to do this properly, in code, rather than a fairly nasty command line adaption. Most daemon programs do return to the background once they've set themselves up, such as fetchmail, which runs it's initial check, and then threads into the background.
|
A daemon is a background process without a controlling terminal.
See Unix Programming FAQ |
kewpie - i use this to deprioritize any process i don't want to hog the cpu - i think this might be what you were referring to. the higher the number the priority is set to, the less cpu it uses.
#include <sys/resources.h> #include <unistd.h> void Set_Process_Priority(void){ int prio; prio = getpriority(PRIO_PROCESS, getpid()); setpriority(PRIO_PROCESS, getpid(), prio + 10); } |
Here you go.
Code:
int make_daemon() |
Thanx
Thanx, guys!
That Unix Programming FAQ is great! |
All times are GMT -5. The time now is 09:02 AM. |