Skip to content

Commit

Permalink
fix: correct error while parsing args of subCommand 'run' and 'kill'
Browse files Browse the repository at this point in the history
Signed-off-by: ComixHe <heyuming@deepin.org>
  • Loading branch information
ComixHe committed Dec 2, 2024
1 parent 44c9b61 commit a2d08e5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions apps/ll-box/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,14 @@ int kill(const arg_kill &arg) noexcept

// TODO: maybe use a more efficient way
bool parsed{ false };
auto sigView = std::string_view{ arg.signal };
for (int i = 0; i < NSIG; ++i) {
if (::strsignal(i) == sigView) {
auto sigView = std::string_view{ arg.signal }.substr(3);
for (int i = SIGINT; i < NSIG; ++i) {
const auto *sigName = ::sigabbrev_np(i);
if (sigName == nullptr) {
continue;
}

if (sigName == sigView) {
sig = i;
parsed = true;
break;
Expand Down Expand Up @@ -532,12 +537,11 @@ arg_run subCommand_run(struct argp_state *state)
argv[0] = argv0; // NOLINT
state->next += argc - 1;

if (argv[state->next] == nullptr) { // NOLINT
if (state->argv[state->next] == nullptr) { // NOLINT
argp_failure(state, -1, EINVAL, "container id must be set"); // NOLINT
}
run_arg.container = argv[state->next]; // NOLINT
run_arg.container = state->argv[state->next++]; // NOLINT

state->next += argc;
return run_arg;
}

Expand Down

0 comments on commit a2d08e5

Please sign in to comment.