Debian Codegraph @

texk/xdvik/m4/xdvi-func-setsid-in-fork.m4

raw
1 # Autoconf macros for xdvik.
2 # Copyright (C) 2002 - 2009 Paul Vojta <[email protected]>
3 #
4 # This file is free software; the copyright holder
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
7
8 # XDVI_FUNC_SETSID_IN_VFORK
9 # -------------------------
10 # Check for whether setsid() is allowed within vfork()
11 # (Mac OS X 10.3 (Panther, 11/2003) is one O/S which does not allow this).
12 AC_DEFUN([XDVI_FUNC_SETSID_IN_VFORK],
13 [AS_IF([test "x$ac_cv_func_vfork_works" = xyes],
14 [AC_CACHE_CHECK([for whether setsid() is allowed within vfork()],
15 [xdvi_cv_setsid_in_vfork],
16 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
17 /* Test adapted from Gnu autoconf */
18 /* Thanks to Paul Eggert for this test. */
19 #include <stdio.h>
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 #ifdef HAVE_UNISTD_H
23 #include <unistd.h>
24 #endif
25 #ifdef HAVE_SYS_WAIT_H
26 #include <sys/wait.h>
27 #endif
28 #ifdef HAVE_VFORK_H
29 #include <vfork.h>
30 #endif]],
31 [[
32 pid_t parent = getpid ();
33 pid_t child;
34
35 child = vfork ();
36
37 if (child == 0) {
38 if (setsid () == -1)
39 _exit(1);
40 _exit(0);
41 } else {
42 int status;
43
44 while (wait(&status) != child)
45 ;
46 _exit(
47 /* Was there some problem with vforking? */
48 child < 0
49
50 /* Did the child fail? (This shouldn't happen.) */
51 || status
52 );
53 }]])],
54 [xdvi_cv_setsid_in_vfork=yes],
55 [xdvi_cv_setsid_in_vfork=no],
56 [xdvi_cv_setsid_in_vfork=no # safe value for cross-compiling])])
57 if test "x$xdvi_cv_setsid_in_vfork" = xyes; then
58 AC_DEFINE([HAVE_GOOD_SETSID_VFORK], 1,
59 [Define if your system allows setsid() within vfork().])
60 fi])
61 ]) # XDVI_FUNC_SETSID_IN_VFORK