This is a discussion on How to start a Server prog written in C (using sockets) to start at bootup within the Linux Operating System forums, part of the Unix Operating Systems category; --> How to start a Server prog written in C (using sockets) to start at bootup. I tried adding script ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| How to start a Server prog written in C (using sockets) to start at bootup. I tried adding script to rc5.d? But the problem is that since the server starts listening on a port( 5000) the OS freezes and then I have to bootup in rescue mode to remove that script. All the script does is runs a program calle server written in C. In the script I have followed the start, stop status pattern followed in other rc5.d scripts. |
| |||
| rajanyadav wrote: > How to start a Server prog written in C (using sockets) to start at > bootup. I tried adding script to rc5.d? But the problem is that since > the server starts listening on a port( 5000) the OS freezes and then I > have to bootup in rescue mode to remove that script. > > All the script does is runs a program calle server written in C. > > In the script I have followed the start, stop status pattern followed > in other rc5.d scripts. The scripts in the rc directories are set up for controlling C programs which are specifically written to run as daemons. You cannot start a simple terminal-oriented program and assume that it behaves as a proper daemon. For details, get e.g. the book W Richard Stevens, Advanced Programming in the UNIX Environment and read the chapter on daemons (and all others referred from it). -- Tauno Voipio tauno voipio (at) iki fi |
| |||
| I tried to make that program run as a daemon by using fork. Lets say my server's name is server. If I run it on terminal now I get the shell back and on doing ps -eaf | grep ./server I can see the server is running The I did this Wrote a script called script. I have attached it Placed it in /etc/rc.d/init.c cd /etc/rc5.d ln -s /etc/rc.d/init.d/script S99script ln -s /etc/rc.d/init.d/script K99script Reboot System hangs on blue screen before getting to login screen Please advice what to do Tauno Voipio wrote: > rajanyadav wrote: > > How to start a Server prog written in C (using sockets) to start at > > bootup. I tried adding script to rc5.d? But the problem is that since > > the server starts listening on a port( 5000) the OS freezes and then I > > have to bootup in rescue mode to remove that script. > > > > All the script does is runs a program calle server written in C. > > > > In the script I have followed the start, stop status pattern followed > > in other rc5.d scripts. > > > > The scripts in the rc directories are set up for controlling > C programs which are specifically written to run as daemons. > > You cannot start a simple terminal-oriented program and > assume that it behaves as a proper daemon. > > For details, get e.g. the book > > W Richard Stevens, Advanced Programming in the UNIX > Environment > > and read the chapter on daemons (and all others referred > from it). > > -- > > Tauno Voipio > tauno voipio (at) iki fi |
| |||
| > Tauno Voipio wrote: > >>rajanyadav wrote: >> >>>How to start a Server prog written in C (using sockets) to start at >>>bootup. I tried adding script to rc5.d? But the problem is that since >>>the server starts listening on a port( 5000) the OS freezes and then I >>>have to bootup in rescue mode to remove that script. >>> >>>All the script does is runs a program calle server written in C. >>> >>>In the script I have followed the start, stop status pattern followed >>>in other rc5.d scripts. >> >> >> >>The scripts in the rc directories are set up for controlling >>C programs which are specifically written to run as daemons. >> >>You cannot start a simple terminal-oriented program and >>assume that it behaves as a proper daemon. >> >>For details, get e.g. the book >> >> W Richard Stevens, Advanced Programming in the UNIX >> Environment >> >>and read the chapter on daemons (and all others referred >>from it). >> (-- top-posting corrected - tv --) rajanyadav wrote: > I tried to make that program run as a daemon by using fork. > Lets say my server's name is server. > If I run it on terminal now I get the shell back and on doing ps -eaf > | grep ./server I can see the server is running > The I did this > Wrote a script called script. > I have attached it > Placed it in /etc/rc.d/init.c > cd /etc/rc5.d > ln -s /etc/rc.d/init.d/script S99script > ln -s /etc/rc.d/init.d/script K99script > > Reboot > > System hangs on blue screen before getting to login screen > > Please advice what to do > Please get the reference and READ IT. It's not sufficient to place a process simply into background by a fork()- You need to handle with the process group and console affinities as well. (You could learn to use Google: I got about 6 million hits by 'linux daemon programming'). -- Tauno Voipio tauno voipio (at) iki fi |
| |||
| Tauno Voipio wrote: >> Tauno Voipio wrote: >> >>> rajanyadav wrote: >>> >>>> How to start a Server prog written in C (using sockets) to start at >>>> bootup. I tried adding script to rc5.d? But the problem is that since >>>> the server starts listening on a port( 5000) the OS freezes and then I >>>> have to bootup in rescue mode to remove that script. >>>> >>>> All the script does is runs a program calle server written in C. >>>> >>>> In the script I have followed the start, stop status pattern followed >>>> in other rc5.d scripts. >>> >>> >>> >>> The scripts in the rc directories are set up for controlling >>> C programs which are specifically written to run as daemons. >>> >>> You cannot start a simple terminal-oriented program and >>> assume that it behaves as a proper daemon. >>> >>> For details, get e.g. the book >>> >>> W Richard Stevens, Advanced Programming in the UNIX >>> Environment >>> >>> and read the chapter on daemons (and all others referred >>> from it). >>> > > (-- top-posting corrected - tv --) > > rajanyadav wrote: > > I tried to make that program run as a daemon by using fork. > > Lets say my server's name is server. > > If I run it on terminal now I get the shell back and on doing ps -eaf > > | grep ./server I can see the server is running > > The I did this > > Wrote a script called script. > > I have attached it > > Placed it in /etc/rc.d/init.c > > cd /etc/rc5.d > > ln -s /etc/rc.d/init.d/script S99script > > ln -s /etc/rc.d/init.d/script K99script > > > > Reboot > > > > System hangs on blue screen before getting to login screen > > > > Please advice what to do > > > > Please get the reference and READ IT. It's not sufficient to > place a process simply into background by a fork()- You need > to handle with the process group and console affinities as well. > Try looking at the source of a really simple daemon program. I can;t think of one right now...but... > (You could learn to use Google: I got about 6 million hits > by 'linux daemon programming'). > Mmm;-) |
| ||||
| In article <1157669466.17773.3@proxy01.news.clara.net>, a@b.c (The Natural Philosopher) writes: > Try looking at the source of a really simple daemon program. I can;t > think of one right now...but... http://www.erlenstar.demon.co.uk/unix/faq_toc.html contains a description of the steps required to make your program run as a daemon. This is the reference I successfully used when I needed to do it myself. -- /~\ cgibbs@kltpzyxm.invalid (Charlie Gibbs) \ / I'm really at ac.dekanfrus if you read it the right way. X Top-posted messages will probably be ignored. See RFC1855. / \ HTML will DEFINITELY be ignored. Join the ASCII ribbon campaign! |
| Thread Tools | |
| Display Modes | |
|
|