Back to Operating Systems Home Page
Next: Assig 4 - Reminder:
Up: 1997 term messages
Previous: 1997 term messages
On Wed, 9 Apr 1997, Rob Flores wrote:
> Writing signal handlers for both is an exercise in portability.
> My problem occurs when I try to run a signal handler in SunOS signal mode:
> When my childs exit, the signal handler interrupts my accept system call
> to the socket, and the server can no longer accept connections on the
> socket. (this info courtesy of perror and erno).
Yes, this is an old problem. The portable solution is to check if
accept(2) returns with -1 and errno==EINTR, and in this case
loop back to accept again.
Something like the following should do.
while (! end_of_the_show) {
sock=accept(blah, growl, grumble);
if (-1==sock) {
if (EINTR==errno) {
continue; /* Restart accept */
}
else {
perror("Ouch ouch accept");
end_of_the_show=TRUE;
}
}
else {
process_connection(sock);
}
}
Ciao
Franco
\
Franco Callari