From 08aa15ce4bc70a8e33574f5c7d5ff9bafe745bae Mon Sep 17 00:00:00 2001 From: Jan Rybar Date: Wed, 15 Sep 2021 21:07:43 +1000 Subject: [PATCH] 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 --- NEWS | 1 + sysctl.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index be6359bd..ee21f717 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ procps-ng-NEXT * slabtop: Don't combine d and o options issue #160 * sysctl: Add support for systemd glob patterns issue #191 * sysctl: Check resolved path to be under /proc/sys issue #179 + * sysctl: return non-zero if EINVAL return for write merge #76 * top: added LOGID similar to 3.3.13 ps LUID * top: added EXE identical to 3.3.17 ps EXE * top: exploit some library smaps_rollup provisions issue #112 diff --git a/sysctl.c b/sysctl.c index 41806601..75636b79 100644 --- a/sysctl.c +++ b/sysctl.c @@ -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; } } }