Handle exec error correctly

exec(1) states that exec will only return in case of an error,
and the return value is -1. Therefore, if (!execv(...)) doesn't
make sense.
tingping/wmclass
Matthias Clasen 2015-01-14 22:37:54 -05:00
parent 77a3259083
commit dac709ef1d
2 changed files with 5 additions and 2 deletions

View File

@ -289,7 +289,7 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
g_unsetenv ("LD_LIBRARY_PATH");
g_setenv ("PATH", "/self/bin:/usr/bin", TRUE);
if (!execv (HELPER, (char **)argv_array->pdata))
if (execv (HELPER, (char **)argv_array->pdata) == -1)
{
g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno), "Unable to start app");
goto out;

View File

@ -1156,5 +1156,8 @@ main (int argc,
__debug__(("launch executable %s\n", args[0]));
return execvp (args[0], args);
if (execvp (args[0], args) == -1)
die_with_error ("execvp %s", args[0]);
return 0;
}