开发者

Going from listen and fork to xinetd

开发者 https://www.devze.com 2023-02-27 01:12 出处:网络
I have a piece of C network software that currently works in listen and fork mode. It\'s listening on some server socket and accepts incoming connection. Then it calls the core server 开发者_StackOver

I have a piece of C network software that currently works in listen and fork mode. It's listening on some server socket and accepts incoming connection. Then it calls the core server 开发者_StackOverflow社区function providing the new accepted socket.

Now I'm trying to make that software also work behind xinetd (depending on some runtime parameter). I tried to directly call the core server function providing file descriptor 0 instead of an accepted socket, but this method is just not working. The program immediately stops with a SIG_PIPE.

Is there any obvious reason for such behavior ? My core function performs some low level socket calls and signal handling. Is that supposed to work behind xinetd ?


Not absolutely certain but not everything you can do on a socket handle also works with ordinary file handles. For a start, you can't write to stdin. Also some system calls probably need a socket e.g. recv().

Edit

Another possibility: does your server process close stdin as part of its start up?

0

精彩评论

暂无评论...
验证码 换一张
取 消