sysctl: handle errors when closing FILE streams
This PR fixes two issues when trying to write a kernel parameter with an invalid value. The first issue is a buffer-underread which causes sysctl to segfault on musl-based systems. And the second issue is that we output an updated parameter even if
close_stream indicates that we were unable to close (and especially flush) the FILE buffer.