Problem : I have a server program running which connects to a remote program using TCP sockets. There many of them (say 20). My problem is one of the socket descriptor has gone bad and has recieved EOF. But due to bug in program it never closes it but adds it back to select() set and causes unnecessary pain.What I did to find it : I attached to DDB, and called read(fd,..) to each of them. The bad descriptor returned 0 and I tapped it there.Though this worked for me, but had a cost of wasting bytes from other sockets and the other functions may behave wrongly.What I am looking for is to get an idea on a non-intrusive mechanism that solves my purpose without affecting the running programs.By the way my NetBSD system understands tcsh only.
A script to identify whether a file descriptor has gone bad
shell script;tcsh;socket;netbsd