Please check the GNU Autoconf Macro Archive for Updates
AC-Archive
Autoconf Macro Archive

ac-archive.sf.net: - Project CVS - Download
Macro Index
- AM Support
- C++ Support
- C Support
- Fortran Support
- Java Support
- Cross Compilation
- Installed Packages
- Miscellaneous
- LaTeX Support
- Uncategorized
- archive macros
- adl's macros
- bkorb's macros
- guidod's macros
- latex's macros
- other's macros
- rleigh's macros
- obsoleted macros
- released macros
- search index

Documentation
- Contribute!
- History
- acincludedir m4
- acinclude (tool)
- macro howto
- ax tricks
- maintainers
- License
- Topics

generated...
2007-08-05

(C) 2007 guidod
Download the M4 Source.

acx_func_fork

Back to the Main Page.

Synopsis
ACX_FUNC_FORK
, 
Version

2000-07-19

Author

Mark Elbrecht <snowball3@bigfoot.com>

License

GPLWithACException
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. As a special exception, the respective Autoconf Macro's copyright owner gives unlimited permission to copy, distribute and modify the configure scripts that are the output of Autoconf when processing the Macro. You need not follow the terms of the GNU General Public License when using or distributing such scripts

Category

cryp.to ac-archive's Miscellaneous (released)

Documentation

Check to for a working fork. Use to provide a workaround for systems that don't have a working fork. For example, the workaround for the fork()/exec() sequence for DOS is to use spawn.

Defines HAVE_NO_FORK is fork() doesn't work or isn't implemented.

M4 Source Code
AC_DEFUN([ACX_FUNC_FORK],
[AC_MSG_CHECKING(for a working fork)
AC_CACHE_VAL(acx_cv_func_fork_works,
[AC_REQUIRE([AC_TYPE_PID_T])
AC_REQUIRE([AC_HEADER_SYS_WAIT])
AC_TRY_RUN([#include &lt;sys/types.h&gt;
#ifdef HAVE_SYS_WAIT_H
#include &lt;sys/wait.h&gt;
#endif
#ifdef HAVE_UNISTD_H
#include &lt;unistd.h&gt;
#endif

int main()
{
  int status;
  pid_t child = fork();

  if (child &lt; 0) /* Error */
    return (1);
  else if (child == 0) /* Child */
    return (0);

  /* Parent */
  status = (wait(&amp;status) != child);
  return  (status &gt;= 0) ? 0 : 1;
}
], acx_cv_func_fork_works=yes, acx_cv_func_fork_works=no, acx_cv_func_fork_works=no)
])
AC_MSG_RESULT($acx_cv_func_fork_works)
if test $acx_cv_func_fork_works = no; then
  AC_DEFINE(HAVE_NO_FORK)
fi
])