git » libfiu » commit cee48fd

preload/posix: Improve behaviour on dlopen() failure

author Alberto Bertogli
2009-06-15 03:15:23 UTC
committer Alberto Bertogli
2009-06-16 15:42:54 UTC
parent 31d1f8db15930774388d5ca798c6600fa8ededdf

preload/posix: Improve behaviour on dlopen() failure

We now print to stderr, and exit the process because it really makes no
sense to continue.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

preload/posix/codegen.c +3 -2

diff --git a/preload/posix/codegen.c b/preload/posix/codegen.c
index a267d1c..e783861 100644
--- a/preload/posix/codegen.c
+++ b/preload/posix/codegen.c
@@ -2,6 +2,7 @@
 #include <stdio.h>
 #include <dlfcn.h>
 #include <sys/time.h>
+#include <stdlib.h>
 #include "codegen.h"
 
 /* Dynamically load libc */
@@ -16,8 +17,8 @@ static void __attribute__((constructor(200))) _fiu_init(void)
 
 	_fiu_libc = dlopen("libc.so.6", RTLD_NOW);
 	if (_fiu_libc == NULL) {
-		printf("Error loading libc: %s\n", dlerror());
-		return;
+		fprintf(stderr, "Error loading libc: %s\n", dlerror());
+		exit(1);
 	}
 
 	printd("done\n");