[CRIU] [PATCH v2] scripts: Print error value in case of action script fail

Kirill Tkhai ktkhai at virtuozzo.com
Thu Dec 15 05:24:42 PST 2016


For easier debugging.

v2: Forward scripts messages to criu log using cr_system

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/action-scripts.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/criu/action-scripts.c b/criu/action-scripts.c
index e9260f7..bfa1f82 100644
--- a/criu/action-scripts.c
+++ b/criu/action-scripts.c
@@ -12,6 +12,7 @@
 #include "action-scripts.h"
 #include "pstree.h"
 #include "common/bug.h"
+#include "util.h"
 
 static const char *action_names[ACT_MAX] = {
 	[ ACT_PRE_DUMP ]	= "pre-dump",
@@ -42,7 +43,7 @@ static LIST_HEAD(scripts);
 
 static int run_shell_scripts(const char *action)
 {
-	int ret = 0;
+	int retval = 0;
 	struct script *script;
 	char image_dir[PATH_MAX];
 	static unsigned env_set = 0;
@@ -80,13 +81,18 @@ static int run_shell_scripts(const char *action)
 	}
 
 	list_for_each_entry(script, &scripts, node) {
+		int err;
 		pr_debug("\t[%s]\n", script->path);
-		ret |= system(script->path);
+		err = cr_system(-1, -1, -1, script->path,
+				(char *[]) { script->path, NULL }, 0);
+		if (err)
+			pr_err("Script %s exited with %d\n", script->path, err);
+		retval |= err;
 	}
 
 	unsetenv("CRTOOLS_SCRIPT_ACTION");
 
-	return ret;
+	return retval;
 }
 
 int run_scripts(enum script_actions act)



More information about the CRIU mailing list