]> git.decadent.org.uk Git - nfs-utils.git/blob - aclocal/bsdsignals.m4
Fixed configuration error when --disable-mount was used.
[nfs-utils.git] / aclocal / bsdsignals.m4
1 dnl *********** BSD vs. POSIX signal handling **************
2 AC_DEFUN([AC_BSD_SIGNALS], [
3   AC_MSG_CHECKING(for BSD signal semantics)
4   AC_CACHE_VAL(knfsd_cv_bsd_signals,
5     [AC_TRY_RUN([
6         #include <signal.h>
7         #include <unistd.h>
8         #include <sys/wait.h>
9
10         static int counter = 0;
11         static RETSIGTYPE handler(int num) { counter++; }
12
13         int main()
14         {
15                 int     s;
16                 if ((s = fork()) < 0) return 1;
17                 if (s != 0) {
18                         if (wait(&s) < 0) return 1;
19                         return WIFSIGNALED(s)? 1 : 0;
20                 }
21
22                 signal(SIGHUP, handler);
23                 kill(getpid(), SIGHUP); kill(getpid(), SIGHUP);
24                 return (counter == 2)? 0 : 1;
25         }
26     ], knfsd_cv_bsd_signals=yes, knfsd_cv_bsd_signals=no,
27     [
28       case "$host_os" in
29         *linux*) knfsd_cv_bsd_signals=no;;
30         *bsd*)   knfsd_cv_bsd_signals=yes;;
31         *)       AC_MSG_ERROR([unable to guess signal semantics for $host_os; please set knfsd_cv_bsd_signals]);;
32       esac
33     ])]) dnl
34     AC_MSG_RESULT($knfsd_cv_bsd_signals)
35     test $knfsd_cv_bsd_signals = yes && AC_DEFINE(HAVE_BSD_SIGNALS, 1, [Define this if you want to use BSD signal semantics])
36 ])dnl