in reply to CGI problems - please help

I can't spot anything that could couse this problem (assuming the file permissions are right and your testing procedure was sound). I think you should just play with the code and try to write the program in some other way.

One way I would propose is to get rid of the exec call and instead pull the whole code from the server.cgi into the block where the exec is being called.

By the way there are race conditions in this code. Two (or more) instances of the program can read simultaneusly the "0" value from the pid file and think that they are the first. You should lock the file (see perldoc -f flock).

Replies are listed 'Best First'.
Re: Re: CGI problems - please help
by alikim (Initiate) on Sep 11, 2003 at 13:20 UTC
    Unfortunately, I can't get rid of exec call because the whole idea is that start.cgi is a client programm which must check if server is running and start it if it's not. I can't get rid of location also because start.cgi must then redirect client to a page which will connect to the server via sockets.
      Then you should not use exec to run the server but rather system. With exec the server will keep the socket to the client open. And probably die with SIGPIPE when the client closes it.

      Update: Or you can close the pipe explicitely in the server code.

      I believe you should fork the server before using the exec function.