Skip to content

Commit

Permalink
Ignore -S if there is no swap
Browse files Browse the repository at this point in the history
Instead of exiting with a fatal error, ignore "-S" if there is
zero swap space.

#97
  • Loading branch information
rfjakob committed Nov 3, 2018
1 parent a8f30d7 commit 582ac1b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 4 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ int main(int argc, char* argv[])
have_M = 1;
break;
case 'S':
if (m.SwapTotalKiB == 0) {
warn("warning: -S: total swap is zero, using default percentages\n");
break;
}
tuple = parse_term_kill_tuple(optarg, m.SwapTotalKiB * 100 / 99);
if (strlen(tuple.err)) {
fatal(16, "-S: %s", tuple.err);
Expand Down
1 change: 0 additions & 1 deletion tests/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func TestCli(t *testing.T) {
{args: []string{"-s", "-10"}, code: 16, stderrContains: "fatal", stdoutEmpty: true},
{args: []string{"-M", mem1percent}, code: -1, stderrContains: " 1 %", stdoutContains: memReport},
{args: []string{"-M", "9999999999999999"}, code: 15, stderrContains: "fatal", stdoutEmpty: true},
{args: []string{"-S", "9999999999999999"}, code: 16, stderrContains: "fatal", stdoutEmpty: true},
{args: []string{"-r", "0"}, code: -1, stderrContains: startupMsg, stdoutEmpty: true},
{args: []string{"-r", "0.1"}, code: -1, stderrContains: startupMsg, stdoutContains: memReport},
// Test --avoid and --prefer
Expand Down

0 comments on commit 582ac1b

Please sign in to comment.