Ancalagon
05-23-2007, 03:35 AM
Heya, I am wondering if anyone can help me with a problem I am having with some Unix coding using C.
The coding is for an internet server, I am trying to write in an ability to reboot the server without disconnecting everyone, I have done this before for another code entirely of my own but this one has me puzzled.
The way it works is the following
System info including the listening socket file descriptor is written to disk
File descriptors for all connections are written to disk
SIGALRM signals stopped by setting setitimer to 0
Process calls execlp with the name of the executable
Server starts again, loads all previous data from disk using saved file descriptors for the connections.
The server uses polling to determine when data is available on the socket with read(2), the problem is that after the execlp read for some reason returns 0 which the server treats as 'end of file' and so the client is disconnected.
This has me completely baffled, the code is nearly exact to what I have used before, the only difference is my own code used a nonblocking select(2) for connections.
The system on which it is running is FreeBSD 6 but that shouldn't make any difference anyway.
Thanks
The coding is for an internet server, I am trying to write in an ability to reboot the server without disconnecting everyone, I have done this before for another code entirely of my own but this one has me puzzled.
The way it works is the following
System info including the listening socket file descriptor is written to disk
File descriptors for all connections are written to disk
SIGALRM signals stopped by setting setitimer to 0
Process calls execlp with the name of the executable
Server starts again, loads all previous data from disk using saved file descriptors for the connections.
The server uses polling to determine when data is available on the socket with read(2), the problem is that after the execlp read for some reason returns 0 which the server treats as 'end of file' and so the client is disconnected.
This has me completely baffled, the code is nearly exact to what I have used before, the only difference is my own code used a nonblocking select(2) for connections.
The system on which it is running is FreeBSD 6 but that shouldn't make any difference anyway.
Thanks