Upgrading to 3.3.10
This commit is contained in:
parent
139085e8ac
commit
12e32bcec9
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@
|
|||||||
/procps-ng-3.3.7.tar.xz
|
/procps-ng-3.3.7.tar.xz
|
||||||
/procps-ng-3.3.8.tar.xz
|
/procps-ng-3.3.8.tar.xz
|
||||||
/procps-ng-3.3.9.tar.xz
|
/procps-ng-3.3.9.tar.xz
|
||||||
|
/procps-ng-3.3.10.tar.xz
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
diff -Naur procps-ng-3.3.9.orig/proc/readproc.c procps-ng-3.3.9/proc/readproc.c
|
|
||||||
--- procps-ng-3.3.9.orig/proc/readproc.c 2013-11-25 10:57:32.000000000 +0100
|
|
||||||
+++ procps-ng-3.3.9/proc/readproc.c 2014-01-24 16:20:02.222000000 +0100
|
|
||||||
@@ -686,6 +686,7 @@
|
|
||||||
close(fd);
|
|
||||||
if(n){
|
|
||||||
int i=n;
|
|
||||||
+ while(i && dst[i-1]=='\0') --i; // skip trailing zeros
|
|
||||||
while(i--)
|
|
||||||
if(dst[i]=='\n' || dst[i]=='\0') dst[i]=sep;
|
|
||||||
if(dst[n-1]==' ') dst[n-1]='\0';
|
|
@ -3,24 +3,14 @@
|
|||||||
|
|
||||||
Summary: System and process monitoring utilities
|
Summary: System and process monitoring utilities
|
||||||
Name: procps-ng
|
Name: procps-ng
|
||||||
Version: 3.3.9
|
Version: 3.3.10
|
||||||
Release: 12%{?dist}
|
Release: 1%{?dist}
|
||||||
License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+
|
License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
URL: https://sourceforge.net/projects/procps-ng/
|
URL: https://sourceforge.net/projects/procps-ng/
|
||||||
|
|
||||||
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz
|
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz
|
||||||
|
|
||||||
Patch0: vmstat-wide-not-wide-enough.patch
|
|
||||||
Patch1: ksh-skip-trailing-zeros.patch
|
|
||||||
Patch2: vmstat-timestamps.patch
|
|
||||||
Patch3: watch-fd-leak.patch
|
|
||||||
Patch4: vmstat-format-security.patch
|
|
||||||
Patch5: subtract-shmem-from-cached.patch
|
|
||||||
Patch6: sysctl-linelen-signed.patch
|
|
||||||
Patch7: ps-man-tracing.patch
|
|
||||||
Patch8: revert-cached.patch
|
|
||||||
|
|
||||||
Requires(post): /sbin/ldconfig
|
Requires(post): /sbin/ldconfig
|
||||||
Requires(postun): /sbin/ldconfig
|
Requires(postun): /sbin/ldconfig
|
||||||
|
|
||||||
@ -80,20 +70,17 @@ Obsoletes: procps-devel < 3.2.9-1
|
|||||||
%description devel
|
%description devel
|
||||||
System and process monitoring utilities development headers
|
System and process monitoring utilities development headers
|
||||||
|
|
||||||
|
%package i18n
|
||||||
|
Summary: Internationalization pack for procps-ng
|
||||||
|
Group: Applications/System
|
||||||
|
Requires: %{name} = %{version}-%{release}
|
||||||
|
|
||||||
|
%description i18n
|
||||||
|
Internationalization pack for procps-ng
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n %{name}-%{version}
|
%setup -q -n %{name}-%{version}
|
||||||
|
|
||||||
%patch0 -p1
|
|
||||||
%patch1 -p1
|
|
||||||
%patch2 -p1
|
|
||||||
%patch3 -p1
|
|
||||||
%patch4 -p1
|
|
||||||
%patch5 -p1
|
|
||||||
%patch6 -p1
|
|
||||||
%patch7 -p1
|
|
||||||
%patch8 -p1
|
|
||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
# The following stuff is needed for git archives only
|
# The following stuff is needed for git archives only
|
||||||
#echo "%{version}" > .tarball-version
|
#echo "%{version}" > .tarball-version
|
||||||
@ -108,6 +95,7 @@ autoreconf --verbose --force --install
|
|||||||
--mandir=%{_mandir} \
|
--mandir=%{_mandir} \
|
||||||
--includedir=%{_includedir} \
|
--includedir=%{_includedir} \
|
||||||
--sysconfdir=%{_sysconfdir} \
|
--sysconfdir=%{_sysconfdir} \
|
||||||
|
--localedir=%{_datadir}/locale \
|
||||||
--docdir=/unwanted \
|
--docdir=/unwanted \
|
||||||
--disable-static \
|
--disable-static \
|
||||||
--disable-w-from \
|
--disable-w-from \
|
||||||
@ -130,6 +118,13 @@ make check
|
|||||||
%install
|
%install
|
||||||
make DESTDIR=%{buildroot} install
|
make DESTDIR=%{buildroot} install
|
||||||
|
|
||||||
|
# --localedir doesn't work correctly
|
||||||
|
mv %{buildroot}/share/locale %{buildroot}/usr/share
|
||||||
|
rmdir %{buildroot}/share
|
||||||
|
|
||||||
|
# translated man pages
|
||||||
|
find man-po/ -type d -maxdepth 1 -mindepth 1 | while read dirname; do cp -a $dirname %{buildroot}/usr/share/man/ ; done
|
||||||
|
|
||||||
mkdir -p %{buildroot}%{_sysconfdir}/sysctl.d
|
mkdir -p %{buildroot}%{_sysconfdir}/sysctl.d
|
||||||
|
|
||||||
ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
|
ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
|
||||||
@ -149,9 +144,11 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
|
|||||||
%{_mandir}/man1/*
|
%{_mandir}/man1/*
|
||||||
%{_mandir}/man8/*
|
%{_mandir}/man8/*
|
||||||
%{_mandir}/man5/*
|
%{_mandir}/man5/*
|
||||||
|
%{_mandir}/*/man1/*
|
||||||
|
%{_mandir}/*/man8/*
|
||||||
|
%{_mandir}/*/man5/*
|
||||||
|
|
||||||
%exclude %{_libdir}/libprocps.la
|
%exclude %{_libdir}/libprocps.la
|
||||||
%exclude %{_sysconfdir}/sysctl.conf
|
|
||||||
%exclude /unwanted/*
|
%exclude /unwanted/*
|
||||||
|
|
||||||
%files devel
|
%files devel
|
||||||
@ -160,8 +157,15 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof
|
|||||||
%{_libdir}/libprocps.so
|
%{_libdir}/libprocps.so
|
||||||
%{_libdir}/pkgconfig/libprocps.pc
|
%{_libdir}/pkgconfig/libprocps.pc
|
||||||
%{_includedir}/proc
|
%{_includedir}/proc
|
||||||
|
%{_mandir}/man3/*
|
||||||
|
|
||||||
|
%files i18n
|
||||||
|
%{_datadir}/locale/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Sep 09 2014 Jaromir Capik <jcapik@redhat.com> - 3.3.10-1
|
||||||
|
- Upgrading to 3.3.10
|
||||||
|
|
||||||
* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.3.9-12
|
* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.3.9-12
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
|
||||||
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
diff -Naur procps-ng-3.3.9.orig/ps/ps.1 procps-ng-3.3.9/ps/ps.1
|
|
||||||
--- procps-ng-3.3.9.orig/ps/ps.1 2013-11-25 10:55:25.000000000 +0100
|
|
||||||
+++ procps-ng-3.3.9/ps/ps.1 2014-04-08 15:47:51.743268372 +0200
|
|
||||||
@@ -849,7 +849,10 @@
|
|
||||||
interruptible sleep (waiting for an event to complete)
|
|
||||||
.TP
|
|
||||||
T
|
|
||||||
-stopped, either by a job control signal or because it is being traced
|
|
||||||
+stopped by job control signal
|
|
||||||
+.TP
|
|
||||||
+t
|
|
||||||
+stopped by debugger during the tracing
|
|
||||||
.TP
|
|
||||||
W
|
|
||||||
paging (not valid since the 2.6.xx kernel)
|
|
@ -1,42 +0,0 @@
|
|||||||
diff --git a/free.1 b/free.1
|
|
||||||
index 21cce28..85efef8 100644
|
|
||||||
--- a/free.1
|
|
||||||
+++ b/free.1
|
|
||||||
@@ -32,9 +32,7 @@ kernels 2.6.32, displayed as zero if not available)
|
|
||||||
Memory used by kernel buffers (Buffers in /proc/meminfo)
|
|
||||||
.TP
|
|
||||||
\fBcached\fR
|
|
||||||
-Memory used by the page cache (calculated as Cached - Shmem in
|
|
||||||
-/proc/meminfo - the Cached value is actually the sum of page cache and
|
|
||||||
-tmpfs memory)
|
|
||||||
+Memory used by the page cache (Cached in /proc/meminfo)
|
|
||||||
.SH OPTIONS
|
|
||||||
.TP
|
|
||||||
\fB\-b\fR, \fB\-\-bytes\fR
|
|
||||||
diff --git a/proc/sysinfo.c b/proc/sysinfo.c
|
|
||||||
index e07ca86..85fb0a4 100644
|
|
||||||
--- a/proc/sysinfo.c
|
|
||||||
+++ b/proc/sysinfo.c
|
|
||||||
@@ -682,8 +682,6 @@ nextline:
|
|
||||||
}
|
|
||||||
kb_swap_used = kb_swap_total - kb_swap_free;
|
|
||||||
kb_main_used = kb_main_total - kb_main_free;
|
|
||||||
- /* "Cached" includes "Shmem" - we want only the page cache here */
|
|
||||||
- kb_main_cached -= kb_main_shared;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************/
|
|
||||||
diff --git a/vmstat.8 b/vmstat.8
|
|
||||||
index 2782a42..420d9f3 100644
|
|
||||||
--- a/vmstat.8
|
|
||||||
+++ b/vmstat.8
|
|
||||||
@@ -102,8 +102,7 @@ b: The number of processes in uninterruptible sleep.
|
|
||||||
swpd: the amount of virtual memory used.
|
|
||||||
free: the amount of idle memory.
|
|
||||||
buff: the amount of memory used as buffers.
|
|
||||||
-cache: the amount of memory used as cache (excluding tmpfs memory for
|
|
||||||
-kernels 2.6.32+)
|
|
||||||
+cache: the amount of memory used as cache.
|
|
||||||
inact: the amount of inactive memory. (\-a option)
|
|
||||||
active: the amount of active memory. (\-a option)
|
|
||||||
.fi
|
|
2
sources
2
sources
@ -1 +1 @@
|
|||||||
0980646fa25e0be58f7afb6b98f79d74 procps-ng-3.3.9.tar.xz
|
1fb7f3f6bf92ce6c5c9ed9949ae858fe procps-ng-3.3.10.tar.xz
|
||||||
|
@ -1,155 +0,0 @@
|
|||||||
From 3569c0351fae7797e8d62feae7229d2d6d2aa0a1 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jakob Unterwurzacher <jakobunt@gmail.com>
|
|
||||||
Date: Tue, 18 Feb 2014 22:12:21 +0100
|
|
||||||
Subject: [PATCH] library: properly handle memory used by tmpfs
|
|
||||||
|
|
||||||
tmpfs has become much more widely used since distributions use it for
|
|
||||||
/tmp (Fedora 18+). In /proc/meminfo, memory used by tmpfs is accounted
|
|
||||||
into "Cached" (aka "NR_FILE_PAGES",
|
|
||||||
http://lxr.free-electrons.com/source/mm/shmem.c#L301 ).
|
|
||||||
|
|
||||||
The tools just pass it on, so what top, free and vmstat report as
|
|
||||||
"cached" is the sum of page cache and tmpfs.
|
|
||||||
|
|
||||||
free has the extremely useful "-/+ buffers/cache" output. However, now
|
|
||||||
that tmpfs is accounted into "cached", those numbers are way off once
|
|
||||||
you have big files in /tmp.
|
|
||||||
|
|
||||||
Fortunately, kernel 2.6.32 introduces "Shmem", which makes tmpfs memory
|
|
||||||
usage accessible from userspace (
|
|
||||||
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=4b02108ac1b3354a22b0d83c684797692efdc395 ).
|
|
||||||
|
|
||||||
This patch substracts Shmem from Cached to get the actual page cache
|
|
||||||
memory. This makes both issues mentioned above disappear. For older
|
|
||||||
kernels, Shmem is not available (hence zero) and this patch is no-op.
|
|
||||||
|
|
||||||
Additionally:
|
|
||||||
* Update the man pages of free and vmstat to explain what is happening
|
|
||||||
* Finally drop "MemShared" from the /proc/meminfo parser, it has been
|
|
||||||
dead for 10+ years and is only causing confusion ( removed in kernel
|
|
||||||
2.5.54, see
|
|
||||||
https://git.kernel.org/cgit/linux/kernel/git/tglx/history.git/commit/?id=fe04e9451e5a159247cf9f03c615a4273ac0c571 )
|
|
||||||
---
|
|
||||||
free.1 | 29 ++++++++++++++++++++++++-----
|
|
||||||
proc/sysinfo.c | 8 ++++----
|
|
||||||
proc/sysinfo.h | 3 +--
|
|
||||||
vmstat.8 | 3 ++-
|
|
||||||
4 files changed, 31 insertions(+), 12 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/free.1 b/free.1
|
|
||||||
index 1e8e7ef..21cce28 100644
|
|
||||||
--- a/free.1
|
|
||||||
+++ b/free.1
|
|
||||||
@@ -11,11 +11,30 @@ free \- Display amount of free and used memory in the system
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.B free
|
|
||||||
displays the total amount of free and used physical and swap memory in the
|
|
||||||
-system, as well as the buffers used by the kernel.
|
|
||||||
-The shared memory column represents either the MemShared value (2.4 series
|
|
||||||
-kernels) or the Shmem value (2.6 series kernels and later) taken from the
|
|
||||||
-/proc/meminfo file. The value is zero if none of the entries is exported
|
|
||||||
-by the kernel.
|
|
||||||
+system, as well as the buffers and caches used by the kernel. The
|
|
||||||
+information is gathered by parsing /proc/meminfo. The displayed
|
|
||||||
+columns are:
|
|
||||||
+.TP
|
|
||||||
+\fBtotal\fR
|
|
||||||
+Total installed memory (MemTotal and SwapTotal in /proc/meminfo)
|
|
||||||
+.TP
|
|
||||||
+\fBused\fR
|
|
||||||
+Used memory (calculated as total - free)
|
|
||||||
+.TP
|
|
||||||
+\fBfree\fR
|
|
||||||
+Unused memory (MemFree and SwapFree in /proc/meminfo)
|
|
||||||
+.TP
|
|
||||||
+\fBshared\fR
|
|
||||||
+Memory used (mostly) by tmpfs (Shmem in /proc/meminfo, available on
|
|
||||||
+kernels 2.6.32, displayed as zero if not available)
|
|
||||||
+.TP
|
|
||||||
+\fBbuffers\fR
|
|
||||||
+Memory used by kernel buffers (Buffers in /proc/meminfo)
|
|
||||||
+.TP
|
|
||||||
+\fBcached\fR
|
|
||||||
+Memory used by the page cache (calculated as Cached - Shmem in
|
|
||||||
+/proc/meminfo - the Cached value is actually the sum of page cache and
|
|
||||||
+tmpfs memory)
|
|
||||||
.SH OPTIONS
|
|
||||||
.TP
|
|
||||||
\fB\-b\fR, \fB\-\-bytes\fR
|
|
||||||
diff --git a/proc/sysinfo.c b/proc/sysinfo.c
|
|
||||||
index 1680cc4..e07ca86 100644
|
|
||||||
--- a/proc/sysinfo.c
|
|
||||||
+++ b/proc/sysinfo.c
|
|
||||||
@@ -531,7 +531,6 @@ static int compare_mem_table_structs(const void *a, const void *b){
|
|
||||||
*
|
|
||||||
* MemTotal: 61768 kB old
|
|
||||||
* MemFree: 1436 kB old
|
|
||||||
- * MemShared: 0 kB old (now always zero; not calculated)
|
|
||||||
* Buffers: 1312 kB old
|
|
||||||
* Cached: 20932 kB old
|
|
||||||
* Active: 12464 kB new
|
|
||||||
@@ -560,7 +559,7 @@ static int compare_mem_table_structs(const void *a, const void *b){
|
|
||||||
* Hugepagesize: 4096 kB 2.5.??+
|
|
||||||
*/
|
|
||||||
|
|
||||||
-/* obsolete since 2.6.x, but reused for shmem in 2.6.32+ */
|
|
||||||
+/* Shmem in 2.6.32+ */
|
|
||||||
unsigned long kb_main_shared;
|
|
||||||
/* old but still kicking -- the important stuff */
|
|
||||||
unsigned long kb_main_buffers;
|
|
||||||
@@ -631,14 +630,13 @@ void meminfo(void){
|
|
||||||
{"LowTotal", &kb_low_total},
|
|
||||||
{"Mapped", &kb_mapped}, // kB version of vmstat nr_mapped
|
|
||||||
{"MemFree", &kb_main_free}, // important
|
|
||||||
- {"MemShared", &kb_main_shared}, // obsolete since kernel 2.6! (sharing the variable with Shmem replacement)
|
|
||||||
{"MemTotal", &kb_main_total}, // important
|
|
||||||
{"NFS_Unstable", &kb_nfs_unstable},
|
|
||||||
{"PageTables", &kb_pagetables}, // kB version of vmstat nr_page_table_pages
|
|
||||||
{"ReverseMaps", &nr_reversemaps}, // same as vmstat nr_page_table_pages
|
|
||||||
{"SReclaimable", &kb_swap_reclaimable}, // "swap reclaimable" (dentry and inode structures)
|
|
||||||
{"SUnreclaim", &kb_swap_unreclaimable},
|
|
||||||
- {"Shmem", &kb_main_shared}, // kernel 2.6 and later (sharing the output variable with obsolete MemShared)
|
|
||||||
+ {"Shmem", &kb_main_shared}, // kernel 2.6.32 and later
|
|
||||||
{"Slab", &kb_slab}, // kB version of vmstat nr_slab
|
|
||||||
{"SwapCached", &kb_swap_cached},
|
|
||||||
{"SwapFree", &kb_swap_free}, // important
|
|
||||||
@@ -684,6 +682,8 @@ nextline:
|
|
||||||
}
|
|
||||||
kb_swap_used = kb_swap_total - kb_swap_free;
|
|
||||||
kb_main_used = kb_main_total - kb_main_free;
|
|
||||||
+ /* "Cached" includes "Shmem" - we want only the page cache here */
|
|
||||||
+ kb_main_cached -= kb_main_shared;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************/
|
|
||||||
diff --git a/proc/sysinfo.h b/proc/sysinfo.h
|
|
||||||
index 1eb3472..2291631 100644
|
|
||||||
--- a/proc/sysinfo.h
|
|
||||||
+++ b/proc/sysinfo.h
|
|
||||||
@@ -20,8 +20,7 @@ extern int uptime (double *uptime_secs, double *idle_secs);
|
|
||||||
extern unsigned long getbtime(void);
|
|
||||||
extern void loadavg(double *av1, double *av5, double *av15);
|
|
||||||
|
|
||||||
-
|
|
||||||
-/* obsolete */
|
|
||||||
+/* Shmem in 2.6.32+ */
|
|
||||||
extern unsigned long kb_main_shared;
|
|
||||||
/* old but still kicking -- the important stuff */
|
|
||||||
extern unsigned long kb_main_buffers;
|
|
||||||
diff --git a/vmstat.8 b/vmstat.8
|
|
||||||
index 420d9f3..2782a42 100644
|
|
||||||
--- a/vmstat.8
|
|
||||||
+++ b/vmstat.8
|
|
||||||
@@ -102,7 +102,8 @@ b: The number of processes in uninterruptible sleep.
|
|
||||||
swpd: the amount of virtual memory used.
|
|
||||||
free: the amount of idle memory.
|
|
||||||
buff: the amount of memory used as buffers.
|
|
||||||
-cache: the amount of memory used as cache.
|
|
||||||
+cache: the amount of memory used as cache (excluding tmpfs memory for
|
|
||||||
+kernels 2.6.32+)
|
|
||||||
inact: the amount of inactive memory. (\-a option)
|
|
||||||
active: the amount of active memory. (\-a option)
|
|
||||||
.fi
|
|
||||||
--
|
|
||||||
1.8.4.2
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
|||||||
From: Sami Farin <hvtaifwkbgefbaei@gmail.com>
|
|
||||||
Date: Fri, 14 Mar 2014 00:00:00 -0600
|
|
||||||
Subject: [PATCH] sysctl: increase max supported line length of the conf file
|
|
||||||
|
|
||||||
I ran into this limit with net.ipv4.ip_local_reserved_ports ,
|
|
||||||
sysctl complained about the line after the long line, further
|
|
||||||
slowing down my error hunting.
|
|
||||||
|
|
||||||
Due to fgets usage, increase buffer size to 4096 chars with
|
|
||||||
minimum amount of code changes.
|
|
||||||
|
|
||||||
Signed-off-by: Sami Farin <hvtaifwkbgefbaei@gmail.com>
|
|
||||||
|
|
||||||
--- a/sysctl.c 2013-10-11 02:04:36.000000000 +0300
|
|
||||||
+++ b/sysctl.c 2014-03-01 12:47:47.629400962 +0200
|
|
||||||
@@ -483,14 +483,16 @@ static int pattern_match(const char *str
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
+#define LINELEN 4096
|
|
||||||
+
|
|
||||||
/*
|
|
||||||
* Preload the sysctl's from the conf file. We parse the file and then
|
|
||||||
* reform it (strip out whitespace).
|
|
||||||
*/
|
|
||||||
static int Preload(const char *restrict const filename)
|
|
||||||
{
|
|
||||||
- char oneline[256];
|
|
||||||
- char buffer[256];
|
|
||||||
+ char oneline[LINELEN];
|
|
||||||
+ char buffer[LINELEN];
|
|
||||||
FILE *fp;
|
|
||||||
char *t;
|
|
||||||
int n = 0;
|
|
@ -1,29 +0,0 @@
|
|||||||
diff -Naur procps-ng-3.3.9.orig/vmstat.c procps-ng-3.3.9/vmstat.c
|
|
||||||
--- procps-ng-3.3.9.orig/vmstat.c 2014-02-05 12:55:02.000000000 +0100
|
|
||||||
+++ procps-ng-3.3.9/vmstat.c 2014-02-05 16:58:35.786000000 +0100
|
|
||||||
@@ -204,10 +204,10 @@
|
|
||||||
"%2s %2s %12s %12s %12s %12s %4s %4s %5s %5s %4s %4s %3s %3s %3s %3s %3s";
|
|
||||||
|
|
||||||
|
|
||||||
- printf(w_option ? wide_header : header);
|
|
||||||
+ printf("%s", w_option ? wide_header : header);
|
|
||||||
|
|
||||||
if (t_option) {
|
|
||||||
- printf(timestamp_header);
|
|
||||||
+ printf("%s", timestamp_header);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\n");
|
|
||||||
@@ -528,10 +528,10 @@
|
|
||||||
const char wide_format[] =
|
|
||||||
"%5s %9s %9s %11s %11s %9s %9s %11s %11s %7s %7s";
|
|
||||||
|
|
||||||
- printf(w_option ? wide_header : header);
|
|
||||||
+ printf("%s", w_option ? wide_header : header);
|
|
||||||
|
|
||||||
if (t_option) {
|
|
||||||
- printf(timestamp_header);
|
|
||||||
+ printf("%s", timestamp_header);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\n");
|
|
@ -1,386 +0,0 @@
|
|||||||
From 4fcd56bf582ee2ef5b205625ca3d1bfed90364e9 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jaromir Capik <jcapik@redhat.com>
|
|
||||||
Date: Tue, 4 Feb 2014 19:10:42 +0100
|
|
||||||
Subject: [PATCH] vmstat: Support for timestamps with '-t' & fix for '-wd'
|
|
||||||
|
|
||||||
From now the vmstat can append a timestamp to each line in the
|
|
||||||
VMSTAT and DISKSTAT mode. You can achieve that with the '-t'
|
|
||||||
switch.
|
|
||||||
The '-w' switch now works in the DISKSTAT mode too.
|
|
||||||
---
|
|
||||||
vmstat.8 | 3 +
|
|
||||||
vmstat.c | 197 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
|
|
||||||
2 files changed, 167 insertions(+), 33 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/vmstat.8 b/vmstat.8
|
|
||||||
index ef6cbe9..420d9f3 100644
|
|
||||||
--- a/vmstat.8
|
|
||||||
+++ b/vmstat.8
|
|
||||||
@@ -74,6 +74,9 @@ or 1048576
|
|
||||||
bytes. Note this does not change the swap (si/so) or block (bi/bo)
|
|
||||||
fields.
|
|
||||||
.TP
|
|
||||||
+\fB\-t\fR, \fB\-\-timestamp\fR
|
|
||||||
+Append timestamp to each line
|
|
||||||
+.TP
|
|
||||||
\fB\-w\fR, \fB\-\-wide\fR
|
|
||||||
Wide output mode (useful for systems with higher amount of memory,
|
|
||||||
where the default output mode suffers from unwanted column breakage).
|
|
||||||
diff --git a/vmstat.c b/vmstat.c
|
|
||||||
index c01351d..a84d2d2 100644
|
|
||||||
--- a/vmstat.c
|
|
||||||
+++ b/vmstat.c
|
|
||||||
@@ -43,6 +43,7 @@
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
+#include <time.h>
|
|
||||||
|
|
||||||
#include "c.h"
|
|
||||||
#include "fileutils.h"
|
|
||||||
@@ -75,6 +76,9 @@ static int a_option;
|
|
||||||
/* "-w" means "wide output" */
|
|
||||||
static int w_option;
|
|
||||||
|
|
||||||
+/* "-t" means "show timestamp" */
|
|
||||||
+static int t_option;
|
|
||||||
+
|
|
||||||
static unsigned sleep_time = 1;
|
|
||||||
static int infinite_updates = 0;
|
|
||||||
static unsigned long num_updates;
|
|
||||||
@@ -100,6 +104,7 @@ static void __attribute__ ((__noreturn__))
|
|
||||||
fputs(_(" -p, --partition <dev> partition specific statistics\n"), out);
|
|
||||||
fputs(_(" -S, --unit <char> define display unit\n"), out);
|
|
||||||
fputs(_(" -w, --wide wide output\n"), out);
|
|
||||||
+ fputs(_(" -t, --timestamp show timestamp\n"), out);
|
|
||||||
fputs(USAGE_SEPARATOR, out);
|
|
||||||
fputs(USAGE_HELP, out);
|
|
||||||
fputs(USAGE_VERSION, out);
|
|
||||||
@@ -180,21 +185,33 @@ static int format_1000(unsigned long long val64, char *restrict dst)
|
|
||||||
|
|
||||||
static void new_header(void)
|
|
||||||
{
|
|
||||||
+ struct tm *tm_ptr;
|
|
||||||
+ time_t the_time;
|
|
||||||
+ char timebuf[32];
|
|
||||||
+
|
|
||||||
/* Translation Hint: Translating folloging header & fields
|
|
||||||
* that follow (marked with max x chars) might not work,
|
|
||||||
* unless manual page is translated as well. */
|
|
||||||
-
|
|
||||||
- const char header[] =
|
|
||||||
- "procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----\n";
|
|
||||||
- const char wide_header[] =
|
|
||||||
- "procs -----------------------memory---------------------- ---swap-- -----io---- -system-- --------cpu--------\n";
|
|
||||||
+ const char *header =
|
|
||||||
+ _("procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----");
|
|
||||||
+ const char *wide_header =
|
|
||||||
+ _("procs -----------------------memory---------------------- ---swap-- -----io---- -system-- --------cpu--------");
|
|
||||||
+ const char *timestamp_header = _(" -----timestamp-----");
|
|
||||||
|
|
||||||
const char format[] =
|
|
||||||
- "%2s %2s %6s %6s %6s %6s %4s %4s %5s %5s %4s %4s %2s %2s %2s %2s %2s\n";
|
|
||||||
+ "%2s %2s %6s %6s %6s %6s %4s %4s %5s %5s %4s %4s %2s %2s %2s %2s %2s";
|
|
||||||
const char wide_format[] =
|
|
||||||
- "%2s %2s %12s %12s %12s %12s %4s %4s %5s %5s %4s %4s %3s %3s %3s %3s %3s\n";
|
|
||||||
+ "%2s %2s %12s %12s %12s %12s %4s %4s %5s %5s %4s %4s %3s %3s %3s %3s %3s";
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ printf(w_option ? wide_header : header);
|
|
||||||
+
|
|
||||||
+ if (t_option) {
|
|
||||||
+ printf(timestamp_header);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ printf("\n");
|
|
||||||
|
|
||||||
- printf(w_option ? _(wide_header) : _(header));
|
|
||||||
printf(
|
|
||||||
w_option ? wide_format : format,
|
|
||||||
/* Translation Hint: max 2 chars */
|
|
||||||
@@ -235,6 +252,19 @@ static void new_header(void)
|
|
||||||
_("wa"),
|
|
||||||
/* Translation Hint: max 2 chars */
|
|
||||||
_("st"));
|
|
||||||
+
|
|
||||||
+ if (t_option) {
|
|
||||||
+ (void) time( &the_time );
|
|
||||||
+ tm_ptr = localtime( &the_time );
|
|
||||||
+ if (strftime(timebuf, sizeof(timebuf), "%Z", tm_ptr)) {
|
|
||||||
+ timebuf[strlen(timestamp_header) - 1] = '\0';
|
|
||||||
+ } else {
|
|
||||||
+ timebuf[0] = '\0';
|
|
||||||
+ }
|
|
||||||
+ printf(" %*s", (int)(strlen(timestamp_header) - 1), timebuf);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned long unitConvert(unsigned long size)
|
|
||||||
@@ -247,9 +277,9 @@ static unsigned long unitConvert(unsigned long size)
|
|
||||||
static void new_format(void)
|
|
||||||
{
|
|
||||||
const char format[] =
|
|
||||||
- "%2u %2u %6lu %6lu %6lu %6lu %4u %4u %5u %5u %4u %4u %2u %2u %2u %2u %2u\n";
|
|
||||||
+ "%2u %2u %6lu %6lu %6lu %6lu %4u %4u %5u %5u %4u %4u %2u %2u %2u %2u %2u";
|
|
||||||
const char wide_format[] =
|
|
||||||
- "%2u %2u %12lu %12lu %12lu %12lu %4u %4u %5u %5u %4u %4u %3u %3u %3u %3u %3u\n";
|
|
||||||
+ "%2u %2u %12lu %12lu %12lu %12lu %4u %4u %5u %5u %4u %4u %3u %3u %3u %3u %3u";
|
|
||||||
|
|
||||||
unsigned int tog = 0; /* toggle switch for cleaner code */
|
|
||||||
unsigned int i;
|
|
||||||
@@ -263,6 +293,9 @@ static void new_format(void)
|
|
||||||
unsigned int sleep_half;
|
|
||||||
unsigned long kb_per_page = sysconf(_SC_PAGESIZE) / 1024ul;
|
|
||||||
int debt = 0; /* handle idle ticks running backwards */
|
|
||||||
+ struct tm *tm_ptr;
|
|
||||||
+ time_t the_time;
|
|
||||||
+ char timebuf[32];
|
|
||||||
|
|
||||||
sleep_half = (sleep_time / 2);
|
|
||||||
new_header();
|
|
||||||
@@ -272,6 +305,12 @@ static void new_format(void)
|
|
||||||
cpu_zzz, pgpgin, pgpgout, pswpin, pswpout, intr, ctxt, &running,
|
|
||||||
&blocked, &dummy_1, &dummy_2);
|
|
||||||
|
|
||||||
+ if (t_option) {
|
|
||||||
+ (void) time( &the_time );
|
|
||||||
+ tm_ptr = localtime( &the_time );
|
|
||||||
+ strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm_ptr);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
duse = *cpu_use + *cpu_nic;
|
|
||||||
dsys = *cpu_sys + *cpu_xxx + *cpu_yyy;
|
|
||||||
didl = *cpu_idl;
|
|
||||||
@@ -298,6 +337,12 @@ static void new_format(void)
|
|
||||||
(unsigned)( (100*dstl + divo2) / Div )
|
|
||||||
);
|
|
||||||
|
|
||||||
+ if (t_option) {
|
|
||||||
+ printf(" %s", timebuf);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ printf("\n");
|
|
||||||
+
|
|
||||||
/* main loop */
|
|
||||||
for (i = 1; infinite_updates || i < num_updates; i++) {
|
|
||||||
sleep(sleep_time);
|
|
||||||
@@ -313,6 +358,12 @@ static void new_format(void)
|
|
||||||
pgpgout + tog, pswpin + tog, pswpout + tog, intr + tog,
|
|
||||||
ctxt + tog, &running, &blocked, &dummy_1, &dummy_2);
|
|
||||||
|
|
||||||
+ if (t_option) {
|
|
||||||
+ (void) time( &the_time );
|
|
||||||
+ tm_ptr = localtime( &the_time );
|
|
||||||
+ strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm_ptr);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
duse =
|
|
||||||
cpu_use[tog] - cpu_use[!tog] + cpu_nic[tog] - cpu_nic[!tog];
|
|
||||||
dsys =
|
|
||||||
@@ -364,6 +415,12 @@ static void new_format(void)
|
|
||||||
/* st */
|
|
||||||
(unsigned)( (100*dstl+divo2)/Div )
|
|
||||||
);
|
|
||||||
+
|
|
||||||
+ if (t_option) {
|
|
||||||
+ printf(" %s", timebuf);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -453,11 +510,33 @@ static int diskpartition_format(const char *partition_name)
|
|
||||||
|
|
||||||
static void diskheader(void)
|
|
||||||
{
|
|
||||||
+ struct tm *tm_ptr;
|
|
||||||
+ time_t the_time;
|
|
||||||
+ char timebuf[32];
|
|
||||||
+
|
|
||||||
/* Translation Hint: Translating folloging header & fields
|
|
||||||
* that follow (marked with max x chars) might not work,
|
|
||||||
* unless manual page is translated as well. */
|
|
||||||
- printf(_("disk- ------------reads------------ ------------writes----------- -----IO------\n"));
|
|
||||||
- printf("%5s %6s %6s %7s %7s %6s %6s %7s %7s %6s %6s\n",
|
|
||||||
+ const char *header =
|
|
||||||
+ _("disk- ------------reads------------ ------------writes----------- -----IO------");
|
|
||||||
+ const char *wide_header =
|
|
||||||
+ _("disk- -------------------reads------------------- -------------------writes------------------ ------IO-------");
|
|
||||||
+ const char *timestamp_header = _(" -----timestamp-----");
|
|
||||||
+
|
|
||||||
+ const char format[] =
|
|
||||||
+ "%5s %6s %6s %7s %7s %6s %6s %7s %7s %6s %6s";
|
|
||||||
+ const char wide_format[] =
|
|
||||||
+ "%5s %9s %9s %11s %11s %9s %9s %11s %11s %7s %7s";
|
|
||||||
+
|
|
||||||
+ printf(w_option ? wide_header : header);
|
|
||||||
+
|
|
||||||
+ if (t_option) {
|
|
||||||
+ printf(timestamp_header);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ printf("\n");
|
|
||||||
+
|
|
||||||
+ printf(w_option ? wide_format : format,
|
|
||||||
" ",
|
|
||||||
/* Translation Hint: max 6 chars */
|
|
||||||
_("total"),
|
|
||||||
@@ -479,25 +558,53 @@ static void diskheader(void)
|
|
||||||
_("cur"),
|
|
||||||
/* Translation Hint: max 6 chars */
|
|
||||||
_("sec"));
|
|
||||||
+
|
|
||||||
+ if (t_option) {
|
|
||||||
+ (void) time( &the_time );
|
|
||||||
+ tm_ptr = localtime( &the_time );
|
|
||||||
+ if (strftime(timebuf, sizeof(timebuf), "%Z", tm_ptr)) {
|
|
||||||
+ timebuf[strlen(timestamp_header) - 1] = '\0';
|
|
||||||
+ } else {
|
|
||||||
+ timebuf[0] = '\0';
|
|
||||||
+ }
|
|
||||||
+ printf(" %*s", (int)(strlen(timestamp_header) - 1), timebuf);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void diskformat(void)
|
|
||||||
{
|
|
||||||
+ const char format[] =
|
|
||||||
+ "%-5s %6u %6u %7llu %7u %6u %6u %7llu %7u %6u %6u";
|
|
||||||
+ const char wide_format[] =
|
|
||||||
+ "%-5s %9u %9u %11llu %11u %9u %9u %11llu %11u %7u %7u";
|
|
||||||
+
|
|
||||||
FILE *fDiskstat;
|
|
||||||
struct disk_stat *disks;
|
|
||||||
struct partition_stat *partitions;
|
|
||||||
unsigned long ndisks, i, j, k;
|
|
||||||
- const char format[] = "%-5s %6u %6u %7llu %7u %6u %6u %7llu %7u %6u %6u\n";
|
|
||||||
+ struct tm *tm_ptr;
|
|
||||||
+ time_t the_time;
|
|
||||||
+ char timebuf[32];
|
|
||||||
+
|
|
||||||
|
|
||||||
if ((fDiskstat = fopen("/proc/diskstats", "rb"))) {
|
|
||||||
fclose(fDiskstat);
|
|
||||||
ndisks = getdiskstat(&disks, &partitions);
|
|
||||||
+
|
|
||||||
+ if (t_option) {
|
|
||||||
+ (void) time( &the_time );
|
|
||||||
+ tm_ptr = localtime( &the_time );
|
|
||||||
+ strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm_ptr);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if (!moreheaders)
|
|
||||||
diskheader();
|
|
||||||
for (k = 0; k < ndisks; k++) {
|
|
||||||
if (moreheaders && ((k % height) == 0))
|
|
||||||
diskheader();
|
|
||||||
- printf(format,
|
|
||||||
+ printf(w_option ? wide_format : format,
|
|
||||||
disks[k].disk_name,
|
|
||||||
disks[k].reads,
|
|
||||||
disks[k].merged_reads,
|
|
||||||
@@ -510,31 +617,51 @@ static void diskformat(void)
|
|
||||||
disks[k].inprogress_IO ? disks[k].inprogress_IO / 1000 : 0,
|
|
||||||
disks[k].milli_spent_IO ? disks[k].
|
|
||||||
milli_spent_IO / 1000 : 0);
|
|
||||||
+
|
|
||||||
+ if (t_option) {
|
|
||||||
+ printf(" %s", timebuf);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ printf("\n");
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
free(disks);
|
|
||||||
free(partitions);
|
|
||||||
+
|
|
||||||
for (j = 1; infinite_updates || j < num_updates; j++) {
|
|
||||||
sleep(sleep_time);
|
|
||||||
ndisks = getdiskstat(&disks, &partitions);
|
|
||||||
- for (i = 0; i < ndisks; i++, k++) {
|
|
||||||
- if (moreheaders && ((k % height) == 0))
|
|
||||||
- diskheader();
|
|
||||||
- printf(format,
|
|
||||||
- disks[i].disk_name,
|
|
||||||
- disks[i].reads,
|
|
||||||
- disks[i].merged_reads,
|
|
||||||
- disks[i].reads_sectors,
|
|
||||||
- disks[i].milli_reading,
|
|
||||||
- disks[i].writes,
|
|
||||||
- disks[i].merged_writes,
|
|
||||||
- disks[i].written_sectors,
|
|
||||||
- disks[i].milli_writing,
|
|
||||||
- disks[i].inprogress_IO ? disks[i].inprogress_IO / 1000 : 0,
|
|
||||||
- disks[i].milli_spent_IO ? disks[i].
|
|
||||||
- milli_spent_IO / 1000 : 0);
|
|
||||||
- fflush(stdout);
|
|
||||||
- }
|
|
||||||
+
|
|
||||||
+ if (t_option) {
|
|
||||||
+ (void) time( &the_time );
|
|
||||||
+ tm_ptr = localtime( &the_time );
|
|
||||||
+ strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm_ptr);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ for (i = 0; i < ndisks; i++, k++) {
|
|
||||||
+ if (moreheaders && ((k % height) == 0))
|
|
||||||
+ diskheader();
|
|
||||||
+ printf(w_option ? wide_format : format,
|
|
||||||
+ disks[i].disk_name,
|
|
||||||
+ disks[i].reads,
|
|
||||||
+ disks[i].merged_reads,
|
|
||||||
+ disks[i].reads_sectors,
|
|
||||||
+ disks[i].milli_reading,
|
|
||||||
+ disks[i].writes,
|
|
||||||
+ disks[i].merged_writes,
|
|
||||||
+ disks[i].written_sectors,
|
|
||||||
+ disks[i].milli_writing,
|
|
||||||
+ disks[i].inprogress_IO ? disks[i].inprogress_IO / 1000 : 0,
|
|
||||||
+ disks[i].milli_spent_IO ? disks[i].
|
|
||||||
+ milli_spent_IO / 1000 : 0);
|
|
||||||
+
|
|
||||||
+ if (t_option) {
|
|
||||||
+ printf(" %s", timebuf);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ printf("\n");
|
|
||||||
+ fflush(stdout);
|
|
||||||
+ }
|
|
||||||
free(disks);
|
|
||||||
free(partitions);
|
|
||||||
}
|
|
||||||
@@ -740,6 +867,7 @@ int main(int argc, char *argv[])
|
|
||||||
{"partition", required_argument, NULL, 'p'},
|
|
||||||
{"unit", required_argument, NULL, 'S'},
|
|
||||||
{"wide", no_argument, NULL, 'w'},
|
|
||||||
+ {"timestamp", no_argument, NULL, 't'},
|
|
||||||
{"help", no_argument, NULL, 'h'},
|
|
||||||
{"version", no_argument, NULL, 'V'},
|
|
||||||
{NULL, 0, NULL, 0}
|
|
||||||
@@ -754,7 +882,7 @@ int main(int argc, char *argv[])
|
|
||||||
atexit(close_stdout);
|
|
||||||
|
|
||||||
while ((c =
|
|
||||||
- getopt_long(argc, argv, "afmnsdDp:S:whV", longopts,
|
|
||||||
+ getopt_long(argc, argv, "afmnsdDp:S:wthV", longopts,
|
|
||||||
NULL)) != EOF)
|
|
||||||
switch (c) {
|
|
||||||
case 'V':
|
|
||||||
@@ -820,6 +948,9 @@ int main(int argc, char *argv[])
|
|
||||||
case 'w':
|
|
||||||
w_option = 1;
|
|
||||||
break;
|
|
||||||
+ case 't':
|
|
||||||
+ t_option = 1;
|
|
||||||
+ break;
|
|
||||||
default:
|
|
||||||
/* no other aguments defined yet. */
|
|
||||||
usage(stderr);
|
|
||||||
--
|
|
||||||
1.8.4.2
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
|||||||
diff --git a/vmstat.c b/vmstat.c
|
|
||||||
index 67515c1..c01351d 100644
|
|
||||||
--- a/vmstat.c
|
|
||||||
+++ b/vmstat.c
|
|
||||||
@@ -187,12 +187,12 @@ static void new_header(void)
|
|
||||||
const char header[] =
|
|
||||||
"procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----\n";
|
|
||||||
const char wide_header[] =
|
|
||||||
- "procs ---------------memory-------------- ---swap-- -----io---- -system-- ------cpu-----\n";
|
|
||||||
+ "procs -----------------------memory---------------------- ---swap-- -----io---- -system-- --------cpu--------\n";
|
|
||||||
|
|
||||||
const char format[] =
|
|
||||||
"%2s %2s %6s %6s %6s %6s %4s %4s %5s %5s %4s %4s %2s %2s %2s %2s %2s\n";
|
|
||||||
const char wide_format[] =
|
|
||||||
- "%2s %2s %8s %8s %8s %8s %4s %4s %5s %5s %4s %4s %2s %2s %2s %2s %2s\n";
|
|
||||||
+ "%2s %2s %12s %12s %12s %12s %4s %4s %5s %5s %4s %4s %3s %3s %3s %3s %3s\n";
|
|
||||||
|
|
||||||
printf(w_option ? _(wide_header) : _(header));
|
|
||||||
printf(
|
|
||||||
@@ -249,7 +249,7 @@ static void new_format(void)
|
|
||||||
const char format[] =
|
|
||||||
"%2u %2u %6lu %6lu %6lu %6lu %4u %4u %5u %5u %4u %4u %2u %2u %2u %2u %2u\n";
|
|
||||||
const char wide_format[] =
|
|
||||||
- "%2u %2u %8lu %8lu %8lu %8lu %4u %4u %5u %5u %4u %4u %2u %2u %2u %2u %2u\n";
|
|
||||||
+ "%2u %2u %12lu %12lu %12lu %12lu %4u %4u %5u %5u %4u %4u %3u %3u %3u %3u %3u\n";
|
|
||||||
|
|
||||||
unsigned int tog = 0; /* toggle switch for cleaner code */
|
|
||||||
unsigned int i;
|
|
@ -1,34 +0,0 @@
|
|||||||
From 835b6294d18a6ad79ff56aaeb0038bc6d006384b Mon Sep 17 00:00:00 2001
|
|
||||||
From: Josh Stone <jistone@redhat.com>
|
|
||||||
Date: Tue, 4 Feb 2014 09:46:58 -0800
|
|
||||||
Subject: [PATCH] watch: Don't leak extra fds to the child
|
|
||||||
|
|
||||||
Once the write side of the pipe has been duped to stdout for the child,
|
|
||||||
the original pipefd is no longer needed, so it can be closed to avoid
|
|
||||||
leaking to the child.
|
|
||||||
|
|
||||||
The leak can easily be seen with "watch ls -l /proc/self/fd", but I
|
|
||||||
found this due to "watch lvs" diagnosing itself:
|
|
||||||
|
|
||||||
File descriptor 4 (pipe:[3163616]) leaked on lvs invocation.
|
|
||||||
|
|
||||||
Signed-off-by: Josh Stone <jistone@redhat.com>
|
|
||||||
---
|
|
||||||
watch.c | 1 +
|
|
||||||
1 file changed, 1 insertion(+)
|
|
||||||
|
|
||||||
diff --git a/watch.c b/watch.c
|
|
||||||
index 032dfb7..f0a3ec3 100644
|
|
||||||
--- a/watch.c
|
|
||||||
+++ b/watch.c
|
|
||||||
@@ -387,6 +387,7 @@ static int run_command(char *restrict command, char **restrict command_argv)
|
|
||||||
if (dup2(pipefd[1], 1) < 0) { /* replace stdout with write side of pipe */
|
|
||||||
xerr(3, _("dup2 failed"));
|
|
||||||
}
|
|
||||||
+ close(pipefd[1]); /* once duped, the write fd isn't needed */
|
|
||||||
dup2(1, 2); /* stderr should default to stdout */
|
|
||||||
|
|
||||||
if (flags & WATCH_EXEC) { /* pass command to exec instead of system */
|
|
||||||
--
|
|
||||||
1.8.4.2
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user