From 2d99476b851d50b376bafb2bc12994d8b0950538 Mon Sep 17 00:00:00 2001 From: Pierre-Marc Fournier Date: Wed, 22 Jul 2009 17:34:56 -0400 Subject: [PATCH] add ilbinterfork --- Makefile.am | 2 +- configure.ac | 1 + libinterfork/Makefile.am | 3 +++ libinterfork/interfork.c | 44 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 libinterfork/Makefile.am create mode 100644 libinterfork/interfork.c diff --git a/Makefile.am b/Makefile.am index 1f9ba751..65809787 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = libust tests libmallocwrap ustd ust +SUBDIRS = libust tests libmallocwrap ustd ust libinterfork EXTRA_DIST = share/kernelcompat.h doc diff --git a/configure.ac b/configure.ac index 21e00b58..a8accce4 100644 --- a/configure.ac +++ b/configure.ac @@ -82,6 +82,7 @@ AC_CONFIG_FILES([ tests/hello/Makefile tests/hello2/Makefile libmallocwrap/Makefile + libinterfork/Makefile ustd/Makefile ust/Makefile ]) diff --git a/libinterfork/Makefile.am b/libinterfork/Makefile.am new file mode 100644 index 00000000..11ee0c97 --- /dev/null +++ b/libinterfork/Makefile.am @@ -0,0 +1,3 @@ +lib_LTLIBRARIES = libinterfork.la +libinterfork_la_SOURCES = interfork.c +libinterfork_la_LIBADD = -ldl diff --git a/libinterfork/interfork.c b/libinterfork/interfork.c new file mode 100644 index 00000000..e57b7e59 --- /dev/null +++ b/libinterfork/interfork.c @@ -0,0 +1,44 @@ +/* Copyright (C) 2009 Pierre-Marc Fournier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#define _GNU_SOURCE +#include +#include +#include + +pid_t fork(void) +{ + static pid_t (*plibc_func)(void) = NULL; + + pid_t retval; + + if(plibc_func == NULL) { + plibc_func = dlsym(RTLD_NEXT, "fork"); + if(plibc_func == NULL) { + fprintf(stderr, "libcwrap: unable to find fork\n"); + return NULL; + } + } + + printf("IN FORK!\n"); + retval = plibc_func(); + + if(retval == 0) + ust_fork(); + + return retval; +} -- 2.34.1