[Freeipa-devel] [PATCH] Make child processes exit when parent dies
Simo Sorce
ssorce at redhat.com
Tue Aug 11 17:06:41 UTC 2009
In general patch is fine, just a minor nitpick on the following bit of
code.
On Tue, 2009-08-11 at 16:44 +0200, Jakub Hrozek wrote:
>
> +int die_if_parent_died(void)
> +{
> +#ifdef HAVE_PRCTL
> + int ret;
> +
> + errno = 0;
> + ret = prctl(PR_SET_PDEATHSIG, SIGTERM, 0, 0, 0);
> + if (ret != 0) {
> + ret = errno;
> + DEBUG(2, ("prctl failed [%d]: %s", ret, strerror(ret)));
> + return ret;
> + }
> +#endif
> + return EOK;
> +}
> +
When the whole function have a different behavior depending on an #ifdef
I very much prefer an approach like the following:
#ifdef HAVE_PRCTL
int die_if_parent_died(void)
{
<do your stuff>
return EOK;
}
#else
int die_if_parent_died(void)
{
DEBUG(1, ("PRCTL Unsupported on this platform\n!"));
return EOK;
}
#endif
Simo.
More information about the Freeipa-devel
mailing list