Skip to contentSkip to conversation

tools/power turbostat: return the exit status of a command

PATCH Applied David Arcari 3 participants 4 messages Feb 12, 2019 – Mar 21, 2019 Turbostat utility

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/power turbostat: return the exit status of a command

turbostat failed to return a non-zero exit status even though the supplied command (turbostat <command>) failed. Currently when turbostat forks a command it returns zero instead of the actual exit status of the command. Modify the code to return the exit status.

---
 tools/power/x86/turbostat/turbostat.c | 3 +++
 1 file changed, 3 insertions(+)
tools/power/x86/turbostat/turbostat.c +3 -0
index 9327c0d..c3fad06 100644
@@ -5077,6 +5077,9 @@ int fork_it(char **argv)
 		signal(SIGQUIT, SIG_IGN);
 		if (waitpid(child_pid, &status, 0) == -1)
 			err(status, "waitpid");
+
+		if (WIFEXITED(status))
+			status = WEXITSTATUS(status);
 	}
 	/*
 	 * n.b. fork_it() does not check for errors from for_all_cpus()
Signature · 1 line
1.8.3.1
#1 lore raw

ping -- just want to make sure this doesn't get lost.

Thanks!

Quoted 28 lines · David Arcari

turbostat failed to return a non-zero exit status even though the supplied command (turbostat <command>) failed. Currently when turbostat forks a command it returns zero instead of the actual exit status of the command. Modify the code to return the exit status.

---
 tools/power/x86/turbostat/turbostat.c | 3 +++
 1 file changed, 3 insertions(+)
tools/power/x86/turbostat/turbostat.c +3 -0
index 9327c0d..c3fad06 100644
@@ -5077,6 +5077,9 @@ int fork_it(char **argv)
 		signal(SIGQUIT, SIG_IGN);
 		if (waitpid(child_pid, &status, 0) == -1)
 			err(status, "waitpid");
+
+		if (WIFEXITED(status))
+			status = WEXITSTATUS(status);
 	}
 	/*
 	 * n.b. fork_it() does not check for errors from for_all_cpus()
maintainer Acked-by
#2 lore raw
Quoted 36 lines · David Arcari

ping -- just want to make sure this doesn't get lost.

Thanks!

Quoted 28 lines · David Arcari

turbostat failed to return a non-zero exit status even though the supplied command (turbostat <command>) failed. Currently when turbostat forks a command it returns zero instead of the actual exit status of the command. Modify the code to return the exit status.

---
 tools/power/x86/turbostat/turbostat.c | 3 +++
 1 file changed, 3 insertions(+)
tools/power/x86/turbostat/turbostat.c +3 -0
index 9327c0d..c3fad06 100644
@@ -5077,6 +5077,9 @@ int fork_it(char **argv)
              signal(SIGQUIT, SIG_IGN);
              if (waitpid(child_pid, &status, 0) == -1)
                      err(status, "waitpid");
+
+             if (WIFEXITED(status))
+                     status = WEXITSTATUS(status);
      }
      /*
       * n.b. fork_it() does not check for errors from for_all_cpus()
Signature · 1 line
Len Brown, Intel Open Source Technology Center
#3 lore raw
In reply to David Arcari
Quoted 19 lines · CET David Arcari

turbostat failed to return a non-zero exit status even though the supplied command (turbostat <command>) failed. Currently when turbostat forks a command it returns zero instead of the actual exit status of the command. Modify the code to return the exit status.

---
 tools/power/x86/turbostat/turbostat.c | 3 +++
 1 file changed, 3 insertions(+)
tools/power/x86/turbostat/turbostat.c +0 -0
index 9327c0d..c3fad06 100644

tools/power/x86/turbostat/turbostat.c int fork_it(char **argv) · line 5085

Quoted 9 lines
tools/power/x86/turbostat/turbostat.c +3 -0
@@ -5077,6 +5077,9 @@ int fork_it(char **argv)
 		signal(SIGQUIT, SIG_IGN);
 		if (waitpid(child_pid, &status, 0) == -1)
 			err(status, "waitpid");
+
+		if (WIFEXITED(status))
+			status = WEXITSTATUS(status);
 	}
 	/*
 	 * n.b. fork_it() does not check for errors from for_all_cpus()

Applied, thanks!