Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple BSD Sockets question



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:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

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: http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden
References: 
 >Simple BSD Sockets question (From: Mark Gilbert <email@hidden>)
 >Re: Simple BSD Sockets question (From: Pelle Johansson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.