...

View Full Version : execlp/file descriptors (Solved annoyingly)



Ancalagon
05-23-2007, 04: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

Ancalagon
05-23-2007, 05:43 AM
Out of pure chance and boredom I have solved this part of the problem

you must specify a string as the execlp second param, that's it,

execlp(binarypath, NULL, (char*)NULL) does NOT work and gives me an EOF when reading from socket file descriptors

execlp(binarypath, "foo", (char*)NULL) does work

That's annoying lol

~Ancalagon



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum