diff mbox series

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

Message ID 1549982079-23516-1-git-send-email-darcari@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Rafael Wysocki
Headers show
Series tools/power turbostat: return the exit status of a command | expand

Commit Message

David Arcari Feb. 12, 2019, 2:34 p.m. UTC
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.

Signed-off-by: David Arcari <darcari@redhat.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Jirka Hladky <jhladky@redhat.com>
Cc: linux-kernel@vger.kernel.org
---
 tools/power/x86/turbostat/turbostat.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

David Arcari Feb. 20, 2019, 1:55 p.m. UTC | #1
ping -- just want to make sure this doesn't get lost.

Thanks!

On 02/12/2019 09:34 AM, David Arcari wrote:
> 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.
> 
> Signed-off-by: David Arcari <darcari@redhat.com>
> Cc: Len Brown <len.brown@intel.com>
> Cc: Jirka Hladky <jhladky@redhat.com>
> Cc: linux-kernel@vger.kernel.org
> ---
>  tools/power/x86/turbostat/turbostat.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
> index 9327c0d..c3fad06 100644
> --- a/tools/power/x86/turbostat/turbostat.c
> +++ b/tools/power/x86/turbostat/turbostat.c
> @@ -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()
>
Len Brown March 19, 2019, 3:12 p.m. UTC | #2
Acked-by: Len Brown <len.brown@intel.com>

On Wed, Feb 20, 2019 at 5:55 AM David Arcari <darcari@redhat.com> wrote:
>
>
> ping -- just want to make sure this doesn't get lost.
>
> Thanks!
>
> On 02/12/2019 09:34 AM, David Arcari wrote:
> > 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.
> >
> > Signed-off-by: David Arcari <darcari@redhat.com>
> > Cc: Len Brown <len.brown@intel.com>
> > Cc: Jirka Hladky <jhladky@redhat.com>
> > Cc: linux-kernel@vger.kernel.org
> > ---
> >  tools/power/x86/turbostat/turbostat.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
> > index 9327c0d..c3fad06 100644
> > --- a/tools/power/x86/turbostat/turbostat.c
> > +++ b/tools/power/x86/turbostat/turbostat.c
> > @@ -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()
> >
>
Rafael J. Wysocki March 21, 2019, 11:26 p.m. UTC | #3
On Tuesday, February 12, 2019 3:34:39 PM CET David Arcari wrote:
> 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.
> 
> Signed-off-by: David Arcari <darcari@redhat.com>
> Cc: Len Brown <len.brown@intel.com>
> Cc: Jirka Hladky <jhladky@redhat.com>
> Cc: linux-kernel@vger.kernel.org
> ---
>  tools/power/x86/turbostat/turbostat.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
> index 9327c0d..c3fad06 100644
> --- a/tools/power/x86/turbostat/turbostat.c
> +++ b/tools/power/x86/turbostat/turbostat.c
> @@ -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!
diff mbox series

Patch

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 9327c0d..c3fad06 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -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()