!1704 devicedebug help优化:仿照aa,在输入错误指令的情况下给予提示,并告知signal信号范围

Merge pull request !1704 from 王达/hotfix/20241104
This commit is contained in:
openharmony_ci 2024-11-15 07:39:08 +00:00 committed by Gitee
commit f47b3eff9c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 6 additions and 4 deletions

View File

@ -38,7 +38,7 @@ APPSPAWN_STATIC int DeviceDebugShowHelp(int argc, char *argv[])
printf("\r\nusage: devicedebug <command> <options>\r\n"
"\r\nThese are common devicedebug commands list:\r\n"
"\r\n help list available commands"
"\r\n kill send a signal to a process\r\n");
"\r\n kill send a signal(1-64) to a process\r\n");
return 0;
}
@ -76,7 +76,9 @@ int main(int argc, char *argv[])
/* 检验用户命令,获取对应的处理函数 */
cmdInfo = DeviceDebugCmdCheck(argv[DEVICEDEBUG_NUM_1]);
if (cmdInfo == NULL) {
DEVICEDEBUG_LOGE("invalid cmd!. cmd:%{public}s\r\n", argv[DEVICEDEBUG_NUM_1]);
printf("devicedebug: '%s' is not a valid devicedebug command. See 'devicedebug help'.",
argv[DEVICEDEBUG_NUM_1]);
DeviceDebugShowHelp(argc, argv);
return DEVICEDEBUG_ERRNO_OPERATOR_TYPE_INVALID;
}

View File

@ -36,7 +36,7 @@ APPSPAWN_STATIC void DeviceDebugShowKillHelp(void)
printf("\r\nusage: devicedebug kill [options] <pid>"
"\r\noptions list:"
"\r\n -h, --help list available commands"
"\r\n kill -<signal> <pid> send a signal to a process\r\n");
"\r\n kill -<signal> <pid> send a signal(1-64) to a process\r\n");
}
APPSPAWN_STATIC char* DeviceDebugJsonStringGeneral(int pid, const char *op, cJSON *args)
@ -133,7 +133,7 @@ int DeviceDebugCmdKill(int argc, char *argv[])
int signal = atoi(argv[DEVICEDEBUG_KILL_CMD_SIGNAL_INDEX] + 1);
if (signal > SIGRTMAX || signal <= 0) {
DEVICEDEBUG_LOGE("signal is %{public}d > %{public}d", signal, SIGRTMAX);
DEVICEDEBUG_LOGE("signal is %{public}d not in [1, %{public}d]", signal, SIGRTMAX);
DeviceDebugShowKillHelp();
return DEVICEDEBUG_ERRNO_PARAM_INVALID;
}