Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!bloom-beacon!tut.cis.ohio-state.edu!ucbvax!ulysses!kpv From: kpv@ulysses.homer.nj.att.com (Phong Vo[drew]) Newsgroups: comp.lang.c Subject: Re: malloc's and signals -- a dangerous mixture? Summary: never ever call malloc in a signal handler Keywords: C,UNIX,malloc,signal Message-ID: <11778@ulysses.homer.nj.att.com> Date: 11 Jul 89 03:48:19 GMT References: <1064@dinl.mmc.UUCP> Organization: AT&T Bell Laboratories, Murray Hill Lines: 10 In article <1064@dinl.mmc.UUCP>, noren@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.