procps/procps-v3.3.3-fdleak.dif
2012-06-04 14:22:08 +00:00

38 lines
849 B
Plaintext

--- vmstat.c
+++ vmstat.c 2012-06-01 15:57:49.952010091 +0000
@@ -41,9 +41,9 @@
#include <sys/dir.h>
#include <sys/ioctl.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <termios.h>
#include <unistd.h>
-
#include "c.h"
#include "fileutils.h"
#include "nls.h"
@@ -545,13 +545,12 @@ static void slabheader(void)
static void slabformat(void)
{
- FILE *fSlab;
+ struct stat fSlab;
struct slab_cache *slabs;
unsigned long nSlab, i, j, k;
const char format[] = "%-24s %6u %6u %6u %6u\n";
- fSlab = fopen("/proc/slabinfo", "rb");
- if (!fSlab) {
+ if (stat("/proc/slabinfo", &fSlab) < 0) {
xwarnx(_("your kernel does not support slabinfo or your permissions are insufficient"));
return;
}
@@ -583,7 +582,6 @@ static void slabformat(void)
}
free(slabs);
}
- fclose(fSlab);
}
static void disksum_format(void)