Re: Simple BSD Sockets question
Re: Simple BSD Sockets question
- Subject: Re: Simple BSD Sockets question
- From: Paul Forgey <email@hidden>
- Date: Wed, 24 Nov 2004 15:20:44 -0800
In my experience, it's a lot more reliable to close the socket unless
the signal handler exits the process. Taking a sideways exit out of
the process is fine for simple things, but gets ugly if you need to
cleanly shut things down (like database files), especially if you have
threads.
If you depend on accept failing with EINTR, the signal may not arrive
while blocking on the accept call. If you happen to get the signal
just before or after the accept call, you won't notice. Polling a
global shutdown flag set in the signal handler still doesn't help
because you may get the signal after checking the flag but before
blocking in the accept call.
In your case, you could just close the socket in the signal handler.
On Nov 24, 2004, at 9:56 AM, Pelle Johansson wrote:
Send the process a signal you are catching, the system call will then
interrupt and return.
--
Pelle Johansson
<email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden