File procps-ng-3.3.9-sysctl-iobuf.patch of Package procps.openSUSE_Leap_42.3_Update
---
sysctl.c | 10 ++++++++++
1 file changed, 10 insertions(+)
--- sysctl.c
+++ sysctl.c 2017-07-06 09:35:09.128849737 +0000
@@ -160,6 +160,8 @@ static char *StripLeadingAndTrailingSpac
/*
* Read a sysctl setting
*/
+#define IOBUFSIZ (128<<10)
+static char *iobuf;
static int ReadSetting(const char *restrict const name)
{
int rc = 0;
@@ -217,6 +219,9 @@ static int ReadSetting(const char *restr
fp = fopen(tmpname, "r");
+ if (iobuf)
+ setvbuf(fp, iobuf, _IOFBF, IOBUFSIZ);
+
if (!fp) {
switch (errno) {
case ENOENT:
@@ -432,6 +437,9 @@ static int WriteSetting(const char *sett
fp = fopen(tmpname, "w");
+ if (iobuf)
+ setvbuf(fp, iobuf, _IOFBF, IOBUFSIZ);
+
if (!fp) {
switch (errno) {
case ENOENT:
@@ -793,6 +801,8 @@ int main(int argc, char *argv[])
argc -= optind;
argv += optind;
+ iobuf = (char*)malloc(IOBUFSIZ); /* Allow to fail */
+
if (DisplayAllOpt)
return DisplayAll(PROC_PATH);