594 |
[Define if you have the `getmntent' function.])])]) |
[Define if you have the `getmntent' function.])])]) |
595 |
|
|
596 |
|
|
|
# _AC_FUNC_GETPGRP_TEST |
|
|
# --------------------- |
|
|
# A program that exits with success iff `getpgrp' seems to ignore its |
|
|
# argument. |
|
|
m4_define([_AC_FUNC_GETPGRP_TEST], |
|
|
[AC_LANG_SOURCE([AC_INCLUDES_DEFAULT] |
|
|
[[ |
|
|
/* |
|
|
* If this system has a BSD-style getpgrp(), |
|
|
* which takes a pid argument, exit unsuccessfully. |
|
|
* |
|
|
* Snarfed from Chet Ramey's bash pgrp.c test program |
|
|
*/ |
|
|
|
|
|
int pid; |
|
|
int pg1, pg2, pg3, pg4; |
|
|
int ng, np, s, child; |
|
|
|
|
|
int |
|
|
main () |
|
|
{ |
|
|
pid = getpid (); |
|
|
pg1 = getpgrp (0); |
|
|
pg2 = getpgrp (); |
|
|
pg3 = getpgrp (pid); |
|
|
pg4 = getpgrp (1); |
|
|
|
|
|
/* If all of these values are the same, it's pretty sure that we're |
|
|
on a system that ignores getpgrp's first argument. */ |
|
|
if (pg2 == pg4 && pg1 == pg3 && pg2 == pg3) |
|
|
exit (0); |
|
|
|
|
|
child = fork (); |
|
|
if (child < 0) |
|
|
exit(1); |
|
|
else if (child == 0) |
|
|
{ |
|
|
np = getpid (); |
|
|
/* If this is Sys V, this will not work; pgrp will be set to np |
|
|
because setpgrp just changes a pgrp to be the same as the |
|
|
pid. */ |
|
|
setpgrp (np, pg1); |
|
|
ng = getpgrp (0); /* Same result for Sys V and BSD */ |
|
|
if (ng == pg1) |
|
|
exit (1); |
|
|
else |
|
|
exit (0); |
|
|
} |
|
|
else |
|
|
{ |
|
|
wait (&s); |
|
|
exit (s>>8); |
|
|
} |
|
|
}]]) |
|
|
])# _AC_FUNC_GETPGRP_TEST |
|
|
|
|
|
|
|
597 |
# AC_FUNC_GETPGRP |
# AC_FUNC_GETPGRP |
598 |
# --------------- |
# --------------- |
599 |
# Figure out whether getpgrp takes an argument or not. Try first using |
# Figure out whether getpgrp requires zero arguments. |
|
# prototypes (AC_COMPILE), and if the compiler is of no help, try a runtime |
|
|
# test. |
|
600 |
AC_DEFUN([AC_FUNC_GETPGRP], |
AC_DEFUN([AC_FUNC_GETPGRP], |
601 |
[AC_CACHE_CHECK(whether getpgrp takes no argument, ac_cv_func_getpgrp_void, |
[AC_CACHE_CHECK(whether getpgrp requires zero arguments, |
602 |
|
ac_cv_func_getpgrp_void, |
603 |
[# Use it with a single arg. |
[# Use it with a single arg. |
604 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [getpgrp (0);])], |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [getpgrp (0);])], |
605 |
[ac_func_getpgrp_1=yes], |
[ac_cv_func_getpgrp_void=no], |
606 |
[ac_func_getpgrp_1=no]) |
[ac_cv_func_getpgrp_void=yes]) |
|
# Use it with no arg. |
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [getpgrp ();])], |
|
|
[ac_func_getpgrp_0=yes], |
|
|
[ac_func_getpgrp_0=no]) |
|
|
# If both static checks agree, we are done. |
|
|
case $ac_func_getpgrp_0:$ac_func_getpgrp_1 in |
|
|
yes:no) ac_cv_func_getpgrp_void=yes;; |
|
|
no:yes) ac_cv_func_getpgrp_void=false;; |
|
|
*) AC_RUN_IFELSE([_AC_FUNC_GETPGRP_TEST], |
|
|
[ac_cv_func_getpgrp_void=yes], |
|
|
[ac_cv_func_getpgrp_void=no], |
|
|
[AC_MSG_ERROR([cannot check getpgrp if cross compiling])]);; |
|
|
esac # $ac_func_getpgrp_0:$ac_func_getpgrp_1 |
|
607 |
]) |
]) |
608 |
if test $ac_cv_func_getpgrp_void = yes; then |
if test $ac_cv_func_getpgrp_void = yes; then |
609 |
AC_DEFINE(GETPGRP_VOID, 1, |
AC_DEFINE(GETPGRP_VOID, 1, |
610 |
[Define if the `getpgrp' function takes no argument.]) |
[Define if the `getpgrp' function requires zero arguments.]) |
611 |
fi |
fi |
612 |
])# AC_FUNC_GETPGRP |
])# AC_FUNC_GETPGRP |
613 |
|
|