malloc() problem solved(?)
Conor P. Cahill
cpcahil at virtech.uucp
Thu Apr 11 00:41:36 AEST 1991
drich at dialogic.com (Dan Rich) writes:
>So, it looks like the solution to this problem is to not put mallocs
>in your signal handlers. :-(
Signal handlers, like the low level kernel stuff, must ensure that
they don't do something that will effect the outside world without
ensuring that they cannot be interrupted. This includes mallocs,
changes to global data (especially pointers), etc.
The kernel's solution is to lock out interrupts that may collide. C
programs can do the same with signals (put the problem signals in
a hold status - see sigset()). However, you still end up with the
limitation that must be very carefull about modifying global
pointers.
The complete answer to the malloc problem would include changes to
malloc that locked out problem signals while the malloc was being
performed.
Remember, signal handlers can be called when you code is at
any location (although because of the way the kernel implements them
they will usually be called near a system call).
--
Conor P. Cahill (703)430-9247 Virtual Technologies, Inc.
uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160
Sterling, VA 22170
More information about the Comp.unix.sysv386
mailing list