autoconf
[Top][All Lists]
Advanced

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

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


From: Bob Friesenhahn
Subject: Re: [configure.ac/uClinux] Adding code for fork/vfork?
Date: Sat, 16 Apr 2011 09:27:37 -0500 (CDT)
User-agent: Alpine 2.01 (GSO 1266 2009-07-14)

On Sat, 16 Apr 2011, Gilles wrote:

On Sat, 16 Apr 2011 02:31:56 -0700, Harlan Stenn <address@hidden>
wrote:
A quick hack (and it may not work well) would be to detect these
systems, and stuff in something that effectively does '#define fork
vfork'.

What I'd like, is to learn how to modify the linker so that it
displays a warning instead of an error, like it used to.

Does someone know how to do this?

What you are looking to do ultimately has nothing to do with autoconf. Autoconf is all about configuration prior to compilation of the application software. It has nothing to do with link-time or run-time configuration.

An alternate approach you could use is to use dlopen(0,RTLD_NOLOAD) and then dlsym() to see if the "fork" symbol is available at run time to the running program. If it is available, then use it. This avoids directly linking against fork().

Here is some completely untested code which might even compile:

#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <link.h>

int my_fork_func(void)
{
  void *dl_handle;
  pid_t (*fork_f)(void);
  int status=-1;

  dl_handle=dlopen(0,RTLD_NOLOAD);
  if (dl_handle)
    {
      fork_f=dlsym(dl_handle,"fork");
      if !(fork_f)
        fork_f=dlsym(dl_handle,"vfork");
      if (fork_f)
        status=fork_f();
      (void) dlclose(dl_handle);
    }
  return status;
}

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]