dnl CF_KILLPG version: 6 updated: 2012/02/13 20:34:56
dnl ---------
dnl Note: relies upon AC_FUNC_SETPGRP, but cannot use AC_REQUIRE, since that
dnl messes up the messages...
define([CF_KILLPG],
[
if test "$cross_compiling" = yes ; then
	AC_CHECK_FUNC(setpgrp,[
	AC_TRY_COMPILE([
#include <sys/types.h>
#include <signal.h>
],[
    (void) setpgrp();
],
	[AC_DEFINE(SETPGRP_VOID)])])
else
	AC_FUNC_SETPGRP
fi

if test "$cross_compiling" = yes ; then
	AC_CHECK_FUNC(getpgrp,[
	AC_TRY_COMPILE([
#include <sys/types.h>
#include <signal.h>
],[
    (void) getpgrp();
],
	[AC_DEFINE(GETPGRP_VOID)])])
else
	AC_FUNC_GETPGRP
fi

AC_CACHE_CHECK(if killpg is needed, cf_cv_need_killpg,[
AC_TRY_RUN([
#include <sys/types.h>
#include <signal.h>
RETSIGTYPE
handler(s)
    int s;
{
    exit(0);
}

main()
{
#ifdef SETPGRP_VOID
    (void) setpgrp();
#else
    (void) setpgrp(0,0);
#endif
    (void) signal(SIGINT, handler);
    (void) kill(-getpid(), SIGINT);
    ${cf_cv_main_return:-return}(1);
}],
	[cf_cv_need_killpg=no],
	[cf_cv_need_killpg=yes],
	[cf_cv_need_killpg=unknown])
])

test $cf_cv_need_killpg = yes && AC_DEFINE(HAVE_KILLPG)
])dnl
