Index: uspace/srv/loader/main.c
===================================================================
--- uspace/srv/loader/main.c	(revision 47e0a05baa886b025c008b7e51748be0a29cd784)
+++ uspace/srv/loader/main.c	(revision 4470e2627030413dc38c0d3b98d9c6a3e1672564)
@@ -47,4 +47,5 @@
 #include <stdlib.h>
 #include <unistd.h>
+#include <bool.h>
 #include <fcntl.h>
 #include <sys/types.h>
@@ -78,5 +79,11 @@
 static char *arg_buf = NULL;
 
-static int loader_get_taskid(ipc_callid_t rid, ipc_call_t *request)
+static elf_info_t prog_info;
+static elf_info_t interp_info;
+
+static bool is_dyn_linked;
+
+
+static void loader_get_taskid(ipc_callid_t rid, ipc_call_t *request)
 {
 	ipc_callid_t callid;
@@ -213,6 +220,5 @@
 }
 
-
-/** Load and run the previously selected program.
+/** Load the previously selected program.
  *
  * @param rid
@@ -220,10 +226,7 @@
  * @return 0 on success, !0 on error.
  */
-static int loader_run(ipc_callid_t rid, ipc_call_t *request)
+static int loader_load(ipc_callid_t rid, ipc_call_t *request)
 {
 	int rc;
-
-	elf_info_t prog_info;
-	elf_info_t interp_info;
 
 //	printf("Load program '%s'\n", pathname);
@@ -246,7 +249,6 @@
 //		printf("Run statically linked program\n");
 //		printf("entry point: 0x%llx\n", prog_info.entry);
+		is_dyn_linked = false;
 		ipc_answer_0(rid, EOK);
-		close_console();
-		elf_run(&prog_info, &pcb);
 		return 0;
 	}
@@ -266,13 +268,36 @@
 	pcb.rtld_bias = RTLD_BIAS;
 
-	printf("run dynamic linker\n");
-	printf("entry point: 0x%llx\n", interp_info.entry);
-	close_console();
-
+	is_dyn_linked = true;
 	ipc_answer_0(rid, EOK);
-	elf_run(&interp_info, &pcb);
+
+	return 0;
+}
+
+
+/** Run the previously loaded program.
+ *
+ * @param rid
+ * @param request
+ * @return 0 on success, !0 on error.
+ */
+static void loader_run(ipc_callid_t rid, ipc_call_t *request)
+{
+	if (is_dyn_linked == true) {
+		/* Dynamically linked program */
+		printf("run dynamic linker\n");
+		printf("entry point: 0x%llx\n", interp_info.entry);
+		close_console();
+
+		ipc_answer_0(rid, EOK);
+		elf_run(&interp_info, &pcb);
+
+	} else {
+		/* Statically linked program */
+		close_console();
+		ipc_answer_0(rid, EOK);
+		elf_run(&prog_info, &pcb);
+	} 
 
 	/* Not reached */
-	return 0;
 }
 
@@ -293,6 +318,5 @@
 	while (1) {
 		callid = async_get_call(&call);
-//		printf("received call from phone %d, method=%d\n",
-//			call.in_phone_hash, IPC_GET_METHOD(call));
+
 		switch (IPC_GET_METHOD(call)) {
 		case LOADER_GET_TASKID:
@@ -304,8 +328,11 @@
 		case LOADER_SET_ARGS:
 			loader_set_args(callid, &call);
+			continue;
+		case LOADER_LOAD:
+			loader_load(callid, &call);
+			continue;
 		case LOADER_RUN:
 			loader_run(callid, &call);
-			exit(0);
-			continue;
+			/* Not reached */
 		default:
 			retval = ENOENT;
