From b195870baf2555587d33bd3b79f09c13c2307ac3 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sat, 5 Feb 2011 01:41:30 +0000 Subject: [PATCH] Better handling of execution errors --- src/run.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/run.c b/src/run.c index f8c86f8..537d8a8 100644 --- a/src/run.c +++ b/src/run.c @@ -299,24 +299,30 @@ static void _on_run_execute(gpointer data) static void _execute_watch(GPid pid, gint status, gpointer data) { Run * run = data; + char const * error; if(run->pid != pid) return; /* should not happen */ - if(WIFEXITED(status)) + if(!WIFEXITED(status)) + return; + switch(WEXITSTATUS(status)) { - if(WEXITSTATUS(status) == 127) /* XXX may mean anything... */ - { - if(run->source != 0) - g_source_remove(run->source); - run->source = 0; - gtk_widget_show(run->window); - _run_error(run, _("Child exited with error code 127"), - 0); + case 127: + error = _("Command not found"); + break; + case 126: + error = _("Permission denied"); + break; + default: + _execute_save_config(run); + gtk_main_quit(); return; - } - _execute_save_config(run); - gtk_main_quit(); } + if(run->source != 0) + g_source_remove(run->source); + run->source = 0; + gtk_widget_show(run->window); + _run_error(run, error, 0); } static void _execute_save_config(Run * run)