1833555 Members
3108 Online
110061 Solutions
New Discussion

Select not timing out

 
Alan Sengillo
Occasional Contributor

Select not timing out

I am using select to wait for input from a socket. The application is running on 30 systems. On one system every few weeks the select does not timeout. I am running HP/UX 10.20. Here is the code segment. The call WriteToErrorLog opens a file, writes the message then closes the file. When the application hangs I get the first debug message but not the second.


struct timeval timeout;
fd_set mask;
int selectReturnStatus;

timeout.tv_sec = 60;
timeout.tv_usec = 0;

FD_ZERO (&mask);
FD_SET (fd, &mask);

WriteToErrorLog("Waiting %d seconds", timeout.tv_sec);

errno = 0;
selectReturnStatus = select (fd + 1, (fd_set *) &mask, (fd_set *) 0, (fd_set *) 0, &timeout);

WriteToErrorLog ( "Done waiting %d", FD_ISSET ( fd, &mask ));