Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-26-2003, 03:36 PM   #1
Registered: Jul 2002
Distribution: Slackware 10.0
Posts: 46

Rep: Reputation: 16
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.
Old 01-26-2003, 06:25 PM   #2
LQ Guru
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,155

Rep: Reputation: 56
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

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

Last edited by DavidPhillips; 01-26-2003 at 06:26 PM.
Old 01-26-2003, 07:29 PM   #3
Registered: Nov 2002
Location: Central VA
Distribution: Ubuntu/Debian
Posts: 228

Rep: Reputation: 32
Check out "Getting a program to run at boot time" at, it may help.

Last edited by cmfarley19; 01-27-2003 at 12:22 PM.
Old 01-27-2003, 12:11 PM   #4
Registered: Jul 2002
Distribution: Slackware 10.0
Posts: 46

Original Poster
Rep: Reputation: 16
ok, thanks for the tips.
Old 01-27-2003, 04:53 PM   #5
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 110Reputation: 110
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&


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.

Last edited by Hko; 01-27-2003 at 04:59 PM.
Old 01-27-2003, 06:40 PM   #6
Registered: Jul 2002
Distribution: Slackware 10.0
Posts: 46

Original Poster
Rep: Reputation: 16
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to start Lisa daemon? deanwhitaker Linux - Newbie 0 03-19-2004 09:17 AM
Start Jabber as daemon jgnasser Linux - Newbie 1 02-16-2004 01:44 PM
Can't get DigiChat Server to start as a daemon hydra_76 Linux - Newbie 1 01-01-2004 05:47 PM
Daemon start order josephswagner Linux - Software 1 03-13-2003 05:49 PM
Getting a daemon to start at boot cmfarley19 Linux - General 5 12-14-2002 03:54 PM

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration