Better handling of execution errors

This commit is contained in:
Pierre Pronchery 2011-02-05 01:41:30 +00:00
parent 8b4f055864
commit b195870baf

View File

@ -299,24 +299,30 @@ static void _on_run_execute(gpointer data)
static void _execute_watch(GPid pid, gint status, gpointer data) static void _execute_watch(GPid pid, gint status, gpointer data)
{ {
Run * run = data; Run * run = data;
char const * error;
if(run->pid != pid) if(run->pid != pid)
return; /* should not happen */ return; /* should not happen */
if(WIFEXITED(status)) if(!WIFEXITED(status))
return;
switch(WEXITSTATUS(status))
{ {
if(WEXITSTATUS(status) == 127) /* XXX may mean anything... */ case 127:
{ error = _("Command not found");
if(run->source != 0) break;
g_source_remove(run->source); case 126:
run->source = 0; error = _("Permission denied");
gtk_widget_show(run->window); break;
_run_error(run, _("Child exited with error code 127"), default:
0); _execute_save_config(run);
gtk_main_quit();
return; 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) static void _execute_save_config(Run * run)