Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    execlp/file descriptors (Solved annoyingly)

    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

    1. System info including the listening socket file descriptor is written to disk
    2. File descriptors for all connections are written to disk
    3. SIGALRM signals stopped by setting setitimer to 0
    4. Process calls execlp with the name of the executable
    5. 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
    Last edited by Ancalagon; 05-23-2007 at 05:47 AM.

  • #2
    New to the CF scene
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I solved it

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •