Re: mach in signal handler
Re: mach in signal handler
- Subject: Re: mach in signal handler
- From: Terry Lambert <email@hidden>
- Date: Mon, 5 Feb 2007 13:49:30 -0800
On Feb 2, 2007, at 11:28 PM, Cyrus Harmon wrote:
On Feb 1, 2007, at 10:04 PM, Terry Lambert wrote:
A good example would be "malloc": it's always wrong to allocate or
free memory in a signal handler.
Hmm... I suppose if malloc is off limits, you're probably going to
tell me I can't call vm_allocate either. damn.
Actually, that one is in theory safe. The vm_allocate() call, unlike
malloc(), doesn't do housekeeping in user space. This tends to make
it more expensive, as well, and it's generally only used for large
(multiples of a page size) allocations.
If you are doing large allocations, then malloc() falls back to
vm_allocate() as well (but does some housekeeping in user space still,
so it's safe to call a corresponding free() for the malloc() call).
Still, as a general rule, you really don't want to do any work in a
signal handler that you don't absolutely need to do, other than
catching the signal and flagging the work to be done later in some
other (non-signal) context.
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden