Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH v3] cpupower: monitor: Exit with error status if execvp() fail
@ 2025-02-20 16:38 Yiwei Lin
  2025-02-20 17:37 ` Shuah Khan
  0 siblings, 1 reply; 3+ messages in thread
From: Yiwei Lin @ 2025-02-20 16:38 UTC (permalink / raw)
  To: trenn, shuah; +Cc: jwyatt, jkacur, linux-pm, linux-kernel, Yiwei Lin

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.

---
V3:
- Modify output message content

V2:
- Check return value from execvp and print message for invalid command
---

Signed-off-by: Yiwei Lin <s921975628@gmail.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..e123aa578881 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("Invalid monitor command %s\n", argv[0]);
+			exit(errno);
+		}
 	} else {
 		/* parent */
 		if (child_pid == -1) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] cpupower: monitor: Exit with error status if execvp() fail
  2025-02-20 16:38 [PATCH v3] cpupower: monitor: Exit with error status if execvp() fail Yiwei Lin
@ 2025-02-20 17:37 ` Shuah Khan
  2025-02-20 17:46   ` Yiwei Lin
  0 siblings, 1 reply; 3+ messages in thread
From: Shuah Khan @ 2025-02-20 17:37 UTC (permalink / raw)
  To: Yiwei Lin, trenn, shuah
  Cc: jwyatt, jkacur, linux-pm, linux-kernel, Shuah Khan

On 2/20/25 09:38, 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.
> 
> ---

Note that everything below this gets thrown away.

> V3:
> - Modify output message content
> 
> V2:
> - Check return value from execvp and print message for invalid command
> ---

These version information goes after the --- below the Signed-off-by

Note that everything below the

> 
> Signed-off-by: Yiwei Lin <s921975628@gmail.com>
> ---

This where the patch version stuff goes. I fixed this for now.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] cpupower: monitor: Exit with error status if execvp() fail
  2025-02-20 17:37 ` Shuah Khan
@ 2025-02-20 17:46   ` Yiwei Lin
  0 siblings, 0 replies; 3+ messages in thread
From: Yiwei Lin @ 2025-02-20 17:46 UTC (permalink / raw)
  To: Shuah Khan, trenn, shuah; +Cc: jwyatt, jkacur, linux-pm, linux-kernel


On 2/21/2025 1:37 AM, Shuah Khan wrote:
> On 2/20/25 09:38, 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.
>>
>> ---
>
> Note that everything below this gets thrown away.
>
>> V3:
>> - Modify output message content
>>
>> V2:
>> - Check return value from execvp and print message for invalid command
>> ---
>
> These version information goes after the --- below the Signed-off-by
>
> Note that everything below the
>
>>
>> Signed-off-by: Yiwei Lin <s921975628@gmail.com>
>> ---
>
> This where the patch version stuff goes. I fixed this for now.
>
Thank you to help for the fix! I'll be careful with the commit message 
next time. I'm sorry if you experienced any inconvenience with this.

All the best,

Yiwei Lin


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-20 17:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-20 16:38 [PATCH v3] cpupower: monitor: Exit with error status if execvp() fail Yiwei Lin
2025-02-20 17:37 ` Shuah Khan
2025-02-20 17:46   ` Yiwei Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox