[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <24f77be1-5b91-4b4b-93eb-4be5d8bd32c1@linuxfoundation.org>
Date: Thu, 20 Feb 2025 09:33:22 -0700
From: Shuah Khan <skhan@...uxfoundation.org>
To: Yiwei Lin <s921975628@...il.com>, trenn@...e.com, shuah@...nel.org
Cc: jwyatt@...hat.com, jkacur@...hat.com, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org, Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH v2] cpupower: monitor: Exit with error status if execvp()
fail
On 2/20/25 06:05, Yiwei Lin wrote:
> In the case that we give a invalid command to idle_monitor for
> monitoring, the execvp() will fail and thus go to the next line.
> As a result, we'll see two differnt monitoring output. For
> example, running `cpupower monitor -i 5 invalidcmd` which `invalidcmd`
> is not executable.
>
> ---
> V2:
> - fix according to review from Shuah
> ---
>
> Signed-off-by: Yiwei Lin <s921975628@...il.com>
> ---
> tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
> index f746099b5dac..7f8958f68eaa 100644
> --- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
> +++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
> @@ -6,6 +6,7 @@
> */
>
>
> +#include <errno.h>
> #include <stdio.h>
> #include <unistd.h>
> #include <stdlib.h>
> @@ -294,7 +295,10 @@ int fork_it(char **argv)
>
> if (!child_pid) {
> /* child */
> - execvp(argv[0], argv);
> + if (execvp(argv[0], argv) == -1) {
> + printf("Fail to execute %s\n", argv[0]);
Invalid monitor command will be a better message than
saying "failed to execute"
thanks,
-- Shuahg
Powered by blists - more mailing lists