malloc's and signals -- a dangerous mixture?
Phong Vo[drew]
kpv at ulysses.homer.nj.att.com
Tue Jul 11 13:48:19 AEST 1989
In article <1064 at dinl.mmc.UUCP>, noren at dinl.uucp (Charles Noren) writes:
> another malloc in a signal handler. Could someone shed some
> light on the subject and possibly provide some rules when
> malloc's are safe (and portable) to use with signals.
As a rule, never call malloc/realloc/free from a signal handler.
At best, you sometimes lose memory. At worst, the arena can be
corrupted causing unexpected program behaviors. For the same reasons,
take extra care to make sure that you are not in a malloc
family call if your handler uses longjmp.
More information about the Comp.lang.c
mailing list