Re: [configure.ac/uClinux] Adding code for fork/vfork?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 14 Apr 2011, Gilles wrote:

However, some applications use if/else blocks just as this one instead
of eg. "#ifdef HAVE_FOR" conditional compiling:
============
if (uClinux) {
	*pid = vfork();
} else {
	*pid = fork();
}
============

Is it possible to modify configure.ac so that it goes ahead and
compiles applications that handle fork/vfork without preprocessor
commands?

The proper solution for this is to have configure test for both fork() and vfork() (and maybe posix_spawn()). Then you have to decide which one you prefer:

In configure.ac:

AC_CHECK_FUNCS([fork posix_spawnp spawnvp vfork])

In the program:

#if HAVE_VFORK
  use vfork
#if HAVE_POSIX_SPAWNP
  use posix_spawn
#if HAVE_SPAWNVP
  use spawnvp
#elif HAVE_FORK
  use fork
#else
#error Need a way to fork a program!
#else

Vfork was supposed to be antique and going away but has been making a resurgence in heavily-threaded programs, however, posix_spawnp() is still preferred in that case (when available).

Bob
--
Bob Friesenhahn
bfriesen@xxxxxxxxxxxxxxxxxxx, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf


[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux