]> git.decadent.org.uk Git - nfs-utils.git/blob - aclocal/bsdsignals.m4
Imported Debian patch 1.0.9-6
[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)]) dnl
27     AC_MSG_RESULT($knfsd_cv_bsd_signals)
28     test $knfsd_cv_bsd_signals = yes && AC_DEFINE(HAVE_BSD_SIGNALS, 1, [Define this if you want to use BSD signal semantics])
29 ])dnl