Skip to content

Commit 80d3175

Browse files
RinHizakurashuahkh
authored andcommitted
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. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Yiwei Lin <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 208baa3 commit 80d3175

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88

9+
#include <errno.h>
910
#include <stdio.h>
1011
#include <unistd.h>
1112
#include <stdlib.h>
@@ -294,7 +295,10 @@ int fork_it(char **argv)
294295

295296
if (!child_pid) {
296297
/* child */
297-
execvp(argv[0], argv);
298+
if (execvp(argv[0], argv) == -1) {
299+
printf("Invalid monitor command %s\n", argv[0]);
300+
exit(errno);
301+
}
298302
} else {
299303
/* parent */
300304
if (child_pid == -1) {

0 commit comments

Comments
 (0)