From cee48fd033580885eab27a422609fc199d4b88eb Mon Sep 17 00:00:00 2001
From: Alberto Bertogli <albertito@blitiri.com.ar>
Date: Mon, 15 Jun 2009 00:15:23 -0300
Subject: [PATCH 27/48] 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 |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

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");
-- 
1.6.2.2.646.gb214

