LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Problem with my Linux daemon (https://www.linuxquestions.org/questions/linux-software-2/problem-with-my-linux-daemon-344956/)

dssoft 07-20-2005 07:09 AM

Problem with my Linux daemon
 
Help me to solve following problem.

I have: Red Hat Linux release 9 (Shrike) + Apache 2.0.40. I have written small PHP script which executes the C++ program (myprogram) using exec() function. myprogram does fork() and runs as daemon. myprogram opens one outbound tcp connection and does not listen any ports. After calling PHP script from browser, it runs C++ program, all works fine.

Now I wish to stop web server. I do: service httpd stop. The server stops. But when I have tried to start it again, have seen such mistake:

make_sock: could not bind to address 0.0.0.0:443
no listening sockets available, shutting down

I have entered netstat -nlp and have seen the following:

Code:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address          Foreign Address        State      PID/Program name
...
tcp        0      0 0.0.0.0:443            0.0.0.0:*              LISTEN      14656/myprogram
...

myprogram listen on server's port! If I start two copies of program, they listen on 80 and 443 ports.

How it can be? And how I can fix it?

Thanks.

foo_bar_foo 07-21-2005 09:43 PM

hi,
i don't know anything about php. but in c exec() actually replaces the calling process so the connection is most likely being passed as an argument to the new process.
also exec() never returns which is why in c you would fork before you use exec so exec becomes a child and gets killed off when the parent dies.


All times are GMT -5. The time now is 08:02 PM.