diff --git a/msg.c b/msg.c index afeac19..a662435 100644 --- a/msg.c +++ b/msg.c @@ -96,7 +96,7 @@ term_kill_tuple_t parse_term_kill_tuple(char* optarg, long upper_limit) } if (tuple.term > upper_limit) { snprintf(tuple.err, sizeof(tuple.err), - "SIGTERM value in '%s' exceeds limit %ld\n", optarg, upper_limit); + "SIGTERM value %ld exceeds limit %ld\n", tuple.term, upper_limit); return tuple; } // User passed only "term" value @@ -105,11 +105,6 @@ term_kill_tuple_t parse_term_kill_tuple(char* optarg, long upper_limit) return tuple; } // User passed "term,kill" values - if (tuple.kill == 0) { - snprintf(tuple.err, sizeof(tuple.err), - "zero SIGKILL value in '%s'\n", optarg); - return tuple; - } if (tuple.kill < 0) { snprintf(tuple.err, sizeof(tuple.err), "negative SIGKILL value in '%s'\n", optarg); diff --git a/tests/c_unit_test.go b/tests/c_unit_test.go index d812582..5c9c5d3 100644 --- a/tests/c_unit_test.go +++ b/tests/c_unit_test.go @@ -36,14 +36,15 @@ func TestParseTuple(t *testing.T) { term int kill int }{ - {arg: "2,1", limit: 100, shouldFail: false, term: 2, kill: 1}, - {arg: "20,10", limit: 100, shouldFail: false, term: 20, kill: 10}, - {arg: "30", limit: 100, shouldFail: false, term: 30, kill: 15}, + {arg: "2,1", limit: 100, term: 2, kill: 1}, + {arg: "20,10", limit: 100, term: 20, kill: 10}, + {arg: "30", limit: 100, term: 30, kill: 15}, {arg: "30", limit: 20, shouldFail: true}, // https://github.com/rfjakob/earlyoom/issues/97 {arg: "22[,20]", limit: 100, shouldFail: true}, {arg: "220[,160]", limit: 300, shouldFail: true}, {arg: "180[,170]", limit: 300, shouldFail: true}, + {arg: "5,0", limit: 100, term: 5, kill: 0}, } for _, tc := range tcs { err, term, kill := parse_term_kill_tuple(tc.arg, tc.limit)