Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12603 Discussions

How to tidy up after client hangup with inetd?

Altera_Forum
Honored Contributor II
1,123 Views

Dear Forum, 

 

My NiosII running uClinux is working as a motion server. I used inetd to listen on a port and launch my server application. Sometimes, the client will make a request that causes the server program to vfork 

and execl another process to deal with the client's request. Normally, the client will end the session with sensible commands and the server program gracefully uses SIGTERM to kill the child processes it has produced. However, when the client severs the connection abruptly, inetd terminates the server program, but the child processes are still runnning. I've tried to fix this problem by catching SIGTERM from inetd in the server program and gracefully terminating the server's child processes. This fails to work when the client abruptly disconnects, yet it works if I kill the server from the terminal with kill <server pid>; I don't understand this failure because inetd.c seems to kill stuff by issuing SIGTERM. What am I missing? 

 

Stephen 

 

Edit: SIGTERM is not the problem, it seems that when a client disconnects abruptly an EOF appears in the the server's stdin stream. This can be used to gracefully reap the server's child processes.
0 Kudos
0 Replies
Reply