LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 01-26-2003, 02:36 PM   #1
champ
Member
 
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.
Thanx.
 
Old 01-26-2003, 05:25 PM   #2
DavidPhillips
Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,154

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 192.168.0.1:192.168.0.201

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


Last edited by DavidPhillips; 01-26-2003 at 05:26 PM.
 
Old 01-26-2003, 06:29 PM   #3
cmfarley19
Member
 
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 farley.no-ip.org/linux/, it may help.

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

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

Rep: Reputation: 108Reputation: 108
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.

Last edited by Hko; 01-27-2003 at 03:59 PM.
 
Old 01-27-2003, 05:40 PM   #6
champ
Member
 
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
 
  


Reply


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 08:17 AM
Start Jabber as daemon jgnasser Linux - Newbie 1 02-16-2004 12:44 PM
Can't get DigiChat Server to start as a daemon hydra_76 Linux - Newbie 1 01-01-2004 04:47 PM
Daemon start order josephswagner Linux - Software 1 03-13-2003 04:49 PM
Getting a daemon to start at boot cmfarley19 Linux - General 5 12-14-2002 02:54 PM


All times are GMT -5. The time now is 06:46 PM.

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