add ilbinterfork
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Wed, 22 Jul 2009 21:34:56 +0000 (17:34 -0400)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Wed, 22 Jul 2009 21:34:56 +0000 (17:34 -0400)
Makefile.am
configure.ac
libinterfork/Makefile.am [new file with mode: 0644]
libinterfork/interfork.c [new file with mode: 0644]

index 1f9ba751ef89192f77d860bc25d7bf601f07a80a..65809787655bac398266a17111bd9606cbcb8b45 100644 (file)
@@ -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
index 21e00b5855651423b4035bcce64af70cfc53d86e..a8accce43802bb1e7181185a8b9c05ee337bc069 100644 (file)
@@ -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 (file)
index 0000000..11ee0c9
--- /dev/null
@@ -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 (file)
index 0000000..e57b7e5
--- /dev/null
@@ -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 <dlfcn.h>
+#include <unistd.h>
+#include <stdio.h>
+
+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;
+}
This page took 0.026702 seconds and 4 git commands to generate.