Hi

I had a client server program executing on two linux machines ( RHEL ).

I am getting different execution bahaviour with the following scenarios:

1) Login to the Server machine as root
Start the Server Program as background process
Login to the Client Machine as root
Start the Client program to connect to the Server

Reboot the Server machine
Client is getting the Socket disconnection event

1) Place the Server program in rc.local file ( to start it as background process, automatically when the system reboots )
reboot the Server machine ( verify that the Server program is started )
Login to the Client Machine as root
Start the Client program to connect to the Server

Reboot the Server machine
Client is NOT getting the Socket disconnection event

Is there any difference between starting the program in command prompt as a root and starting the program from rc.local ?

Starting applications from rc.local will result in the app having different parents, than when starting it from a console.

My guess would be that the app does not handle signals correctly, so it does not get the sigint (whatever signal the shutdown sends). The parent app on the other hand does get it, and handles it correctly (perhaps sending a different signal to your server app - which it handles correctly). So when the parent app dies, your server app probably dies as well.

Running it from rc.local probably leaves it without a clear parent (or the other signal), and thus leaves it to only react to the sighup/whatever signal.

You might try something like a 'screen -d -m servercommand' (simplified). Screen might then close down nicely with the sigint signal, and give your server app sufficient warning. Or perhaps run it from bash with the -c option.

This post seems very confusing to me - but you might get the idea :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.