LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   start server as a daemon (https://www.linuxquestions.org/questions/programming-9/start-server-as-a-daemon-42849/)

champ 01-26-2003 02:36 PM

start server as a daemon
 
I have written a simple dialup server for my home network. But I was just wondering
how to start the server as a background process without to append the '&' when I start
the server? Because when it enters the while loop that waits for connections, it will make my prompt busy.

I can of course just start it with '&', but I was hoping I would'nt have to do that.

Hopefully this will not be a very big problem for you guys.
Thanx.

DavidPhillips 01-26-2003 05:25 PM

Not sure what you are using, mgetty runs in the background and gets started from inittab

S0:2345:respawn:/sbin/mgetty -s 115200 -x 3 ttyS0


the login.conf will start pppd with this command

/AutoPPP/ - a_ppp /usr/sbin/pppd auth -chap +pap login asyncmap 0 192.168.0.1:192.168.0.201

Otherwise just add & to the command or start it on boot from rc.local


cmfarley19 01-26-2003 06:29 PM

Check out "Getting a program to run at boot time" at farley.no-ip.org/linux/, it may help.

champ 01-27-2003 11:11 AM

ok, thanks for the tips.

Hko 01-27-2003 03:53 PM

In what language did you make the program?
If it's C(++) see the man for the daemon() function ("man 3 daemon")

Or if you don't want to change the program, try:

shell> nohup yourprog&

or:

shell> (exec yourprog >/dev/null 2>&1 &)

You'll still need '&', but you can close the terminal (xterm?), without you program being killed.

Another option may be to look for the start-stop-daemon program on your system. On debian it's only in the $PATH or root. Use the -b option.

champ 01-27-2003 05:40 PM

Thanx Hko, the daemon() function was the one i was looking for.
Now the program will fork a process when the program starts. and run as a background process. Super :)


All times are GMT -5. The time now is 07:59 PM.