[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250220163846.2765-1-s921975628@gmail.com>
Date: Fri, 21 Feb 2025 00:38:46 +0800
From: Yiwei Lin <s921975628@...il.com>
To: trenn@...e.com,
shuah@...nel.org
Cc: jwyatt@...hat.com,
jkacur@...hat.com,
linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org,
Yiwei Lin <s921975628@...il.com>
Subject: [PATCH v3] cpupower: monitor: Exit with error status if execvp() fail
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@...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..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
Powered by blists - more mailing lists