hal/hald-runner runner.c,1.4,1.5

David Zeuthen david at freedesktop.org
Sat Jan 28 14:20:38 PST 2006


Update of /cvs/hal/hal/hald-runner
In directory gabe:/tmp/cvs-serv9314/hald-runner

Modified Files:
	runner.c 
Log Message:
2006-01-28  David Zeuthen  <davidz at redhat.com>

        * hald-runner/runner.c (run_request_run): Set working directory
        to where the program exists.



Index: runner.c
===================================================================
RCS file: /cvs/hal/hal/hald-runner/runner.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- runner.c	23 Jan 2006 14:54:48 -0000	1.4
+++ runner.c	28 Jan 2006 22:20:36 -0000	1.5
@@ -225,6 +225,8 @@
 	gint stdin_v;
 	gint stderr_v = -1;
 	run_data *rd = NULL;
+	gboolean program_exists = FALSE;
+	char *program_dir = NULL;
 	GList *list;
 
 	printf("Run started %s (%d) (%d) \n!", r->argv[0], r->timeout,
@@ -236,16 +238,23 @@
 		stderr_p = &stderr_v;
 	}
 
-	if (!find_program(r->argv) ||
-		!g_spawn_async_with_pipes(NULL, r->argv, r->environment,
+	program_exists = find_program(r->argv);
+
+	if (program_exists)
+		program_dir = g_path_get_dirname (r->argv);
+
+	if (!program_exists ||
+		!g_spawn_async_with_pipes(program_dir, r->argv, r->environment,
 		                          G_SPAWN_DO_NOT_REAP_CHILD,
 		                          NULL, NULL, &pid,
 		                          stdin_p, NULL, stderr_p, &error)) {
+		g_free (program_dir);
 		del_run_request(r);
 		if (con && msg)
 			send_reply(con, msg, HALD_RUN_FAILED, 0, NULL);
 		return FALSE;
 	}
+	g_free (program_dir);
 
 	if (r->input) {
 		write(stdin_v, r->input, strlen(r->input));




More information about the hal-commit mailing list