fix spawn commands

This commit is contained in:
Julio Montes
2015-12-08 15:14:47 -06:00
parent 4661ac8cc9
commit df2541a4fd
2 changed files with 16 additions and 4 deletions
+7
View File
@@ -74,6 +74,13 @@ fi
AC_SUBST(RESIZE2FS)
AC_DEFINE_UNQUOTED([RESIZEFS_PATH], ["$RESIZE2FS"], [Path to resize2fs binary])
AC_PATH_PROG([SHELL], [sh], [no], [$PATH:/sbin:/usr/sbin])
if test x"$SHELL" == x"no" ; then
AC_MSG_ERROR([Please install sh.])
fi
AC_SUBST(SHELL)
AC_DEFINE_UNQUOTED([SHELL_PATH], ["$SHELL"], [Path to sh binary])
AC_PATH_PROG([HOSTNAMECTL], [hostnamectl], [no], [$PATH:/sbin:/usr/sbin])
if test x"$HOSTNAMECTL" == x"no" ; then
AC_MSG_ERROR([Please install hostnamectl.])
+9 -4
View File
@@ -75,26 +75,31 @@ bool exec_task(const gchar* command_line) {
GError* error = NULL;
gint exit_status = 0;
gboolean result;
GString* command;
command = g_string_new("");
g_string_printf(command, SHELL_PATH " -c '%s'", (char*)command_line );
LOG(MOD "Executing: %s\n", command_line);
result = g_spawn_command_line_sync(command_line,
LOG(MOD "Executing: %s\n", command->str);
result = g_spawn_command_line_sync(command->str,
&standard_output,
&standard_error,
&exit_status,
&error);
g_string_free(command, true);
if (!result || exit_status != 0) {
LOG(MOD "Command failed\n");
if (error) {
LOG(MOD "Error: %s\n", (char*)error->message);
}
if (standard_error) {
LOG(MOD "STD Error: %s", (char*)standard_error);
LOG(MOD "STD Error: %s\n", (char*)standard_error);
}
}
if (standard_output) {
LOG(MOD "STD output: %s", (char*)standard_output);
LOG(MOD "STD output: %s\n", (char*)standard_output);
g_free(standard_output);
}