[sheepdog] [PATCH]Check malloc error for collie

Hitoshi Mitake mitake.hitoshi at gmail.com
Wed Feb 20 04:57:17 CET 2013


At Wed, 20 Feb 2013 11:03:58 +0800,
harryxiyou wrote:
> 
> On Wed, Feb 20, 2013 at 9:52 AM, Hitoshi Mitake
> <mitake.hitoshi at gmail.com> wrote:
> [...]
> > This is my understanding:
> > 1. replacing malloc() with xmalloc()
> 
> Why should we use xmalloc() instead?

Because we don't have to check return values with xmalloc(). In
xmalloc(), fail of malloc() causes abort() so we can assume returned
pointers always point allocated memory areas.

> 
> 
> > 2. register signal handler for SIGABRT, and let the handler call
> >    exit(EXIT_SYSFAIL)
> 
> I am not sure how & where to register this signal handler for SIGABRT?

At the very begining of collie's main() is suitable. collie has to
register the handler before any other proceduers which has a
possibility of involving abort().

Thanks,
Hitoshi



More information about the sheepdog mailing list