sysctl: Return non-zero if param setting failed

Real usecase:
'sysctl -w user.max_uts_namespaces=2147483648; echo $?'
returns 0 even though it failed with EINVAL

The close_stream() realised there was an issue and printed an
error but didn't change the return value.

Slightly modified merge request.

References:
 procps-ng/procps!76

Signed-off-by: Craig Small <csmall@dropbear.xyz>
This commit is contained in:
Jan Rybar
2021-09-15 21:07:43 +10:00
committed by Craig Small
parent e886010ef7
commit 08aa15ce4b
2 changed files with 2 additions and 1 deletions

View File

@@ -586,7 +586,7 @@ static int WriteSetting(
rc = EXIT_SUCCESS;
if (close_stream(fp) != 0) {
xwarn(_("setting key \"%s\""), path);
return rc;
return EXIT_FAILURE;
}
}
}