Update to 3.3.9
This commit is contained in:
parent
106bb9faa3
commit
5c413895ab
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@
|
||||
/procps-ng-3.3.6.tar.xz
|
||||
/procps-ng-3.3.7.tar.xz
|
||||
/procps-ng-3.3.8.tar.xz
|
||||
/procps-ng-3.3.9.tar.xz
|
||||
|
@ -1,42 +0,0 @@
|
||||
From a6dfe2648a39d5fed8de0361aecf0e035ad80222 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Thu, 6 Jun 2013 00:00:00 -0500
|
||||
Subject: [PATCH] top: add the major version to dlopen of libnuma soname
|
||||
|
||||
When the plug-in approach to NUMA support was added, I
|
||||
carelessly employed the compile-time linker convention
|
||||
for naming the library. Technically this then required
|
||||
the 'devel' package for NUMA support to be present for
|
||||
the unqualified soname symlink to be available. Either
|
||||
that or one must have manually created such a symlink.
|
||||
|
||||
This commit adds the missing major version to dlopen()
|
||||
of libnuma.so.1 so simply having a more likely package
|
||||
such as 'numactl' will enable both '2' & '3' commands.
|
||||
|
||||
References(s):
|
||||
http://www.freelists.org/post/procps/top-NUMA-node-CPU-utilization-support,25
|
||||
. initial dlopen support
|
||||
commit edba932a7e9b950dd91bc486e107788e977a5186
|
||||
|
||||
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
||||
---
|
||||
top/top.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/top/top.c b/top/top.c
|
||||
index c1853ee..1d38c0f 100644
|
||||
--- a/top/top.c
|
||||
+++ b/top/top.c
|
||||
@@ -3246,7 +3246,7 @@ static void before (char *me) {
|
||||
#if defined(PRETEND_NUMA) || defined(PRETEND8CPUS)
|
||||
Numa_node_tot = Numa_max_node() + 1;
|
||||
#else
|
||||
- Libnuma_handle = dlopen("libnuma.so", RTLD_LAZY);
|
||||
+ Libnuma_handle = dlopen("libnuma.so.1", RTLD_LAZY);
|
||||
if (Libnuma_handle) {
|
||||
Numa_max_node = dlsym(Libnuma_handle, "numa_max_node");
|
||||
Numa_node_of_cpu = dlsym(Libnuma_handle, "numa_node_of_cpu");
|
||||
--
|
||||
1.8.1.2
|
||||
|
@ -1,150 +0,0 @@
|
||||
From b765e587bf737efffbfe4fff087452de7a090708 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Fri, 28 Jun 2013 00:00:00 -0500
|
||||
Subject: [PATCH] top: enable screen contents preservation at end-of-job
|
||||
|
||||
The title of this commit is actually quite misleading.
|
||||
|
||||
Were it more accurate, it would at least mention a tty
|
||||
emulator's scrollback buffer, which was the cumulation
|
||||
of a long pursuit to reduce the SIGWINCH overhead when
|
||||
a window manager carelessly floods an application with
|
||||
that signal *while* a user is still resizing a window!
|
||||
|
||||
Disabling and enabling that scrollback buffer resulted
|
||||
in the final top display replaced with original screen
|
||||
contents, a phenomenon acknowledged at the time but it
|
||||
also represented a user interface change which has now
|
||||
produced the first request for return to old behavior.
|
||||
|
||||
After the SIGWINCH dust settled, another problem arose
|
||||
regarding behaviors under the 'screen' window manager.
|
||||
In response, top was refactored a bit to avoid display
|
||||
corruption. That was before discovering 'screen' could
|
||||
duplicate the scrollback buffer behavior top expected.
|
||||
|
||||
As it turns out, the 'screen' refactoring had probably
|
||||
made scrollback buffer manipulation unnecessary. Still
|
||||
one could argue that a window should not be allowed to
|
||||
scroll while a constantly updating program was active.
|
||||
|
||||
The solution represented in this commit returns former
|
||||
behavior at program end (retaining top's last screen).
|
||||
And if we ever wish to disable scrollback buffers, the
|
||||
associated logic was retained but made conditional. It
|
||||
is not reflected in configure.ac but might be someday.
|
||||
|
||||
Lastly, this commit corrects cursor positioning when a
|
||||
^C is issued under 'Fields Management' at any terminal
|
||||
that didn't have a scrollback buffer (i.e. a console).
|
||||
|
||||
Reference(s):
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=977561
|
||||
http://www.freelists.org/post/procps/top-library-miscellaneous-tweaks,1
|
||||
. screen program refactor
|
||||
commit 0fe393ff270922cd4f6edbcaabba006314e73a37
|
||||
. scrollback buffer disabled
|
||||
commit dedaf6e1a81738ff08ee8e8523871e12f555ad6d
|
||||
. sigwinch management defines
|
||||
commit adca737758e5afc7be344a736953931894cbc19f
|
||||
commit 4f33b6b8c56464b4044deb29a3bb0e32622e108f
|
||||
|
||||
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
||||
---
|
||||
top/top.c | 18 +++++++++++-------
|
||||
top/top.h | 1 +
|
||||
2 files changed, 12 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/top/top.c b/top/top.c
|
||||
index 1d38c0f..cdcf3c0 100644
|
||||
--- a/top/top.c
|
||||
+++ b/top/top.c
|
||||
@@ -72,8 +72,9 @@ static struct termios Tty_original, // our inherited terminal definition
|
||||
Tty_raw; // for unsolicited input
|
||||
static int Ttychanged = 0;
|
||||
|
||||
- /* Last established cursor state/shape */
|
||||
+ /* Last established cursor state/shape, and is re-position needed */
|
||||
static const char *Cursor_state = "";
|
||||
+static int Cursor_repos;
|
||||
|
||||
/* Program name used in error messages and local 'rc' file name */
|
||||
static char *Myname;
|
||||
@@ -350,12 +351,15 @@ static void at_eoj (void) {
|
||||
if (Ttychanged) {
|
||||
tcsetattr(STDIN_FILENO, TCSAFLUSH, &Tty_original);
|
||||
if (keypad_local) putp(keypad_local);
|
||||
+ if (Cursor_repos) putp(tg2(0, Screen_rows));
|
||||
putp("\n");
|
||||
+#ifdef OFF_SCROLLBK
|
||||
if (exit_ca_mode) {
|
||||
// this next will also replace top's most recent screen with the
|
||||
// original display contents that were visible at our invocation
|
||||
putp(exit_ca_mode);
|
||||
}
|
||||
+#endif
|
||||
putp(Cap_curs_norm);
|
||||
putp(Cap_clr_eol);
|
||||
#ifndef RMAN_IGNORED
|
||||
@@ -591,17 +595,13 @@ static void sig_endpgm (int dont_care_sig) {
|
||||
|
||||
/*
|
||||
* Catches:
|
||||
- * SIGTSTP, SIGTTIN and SIGTTOU
|
||||
- * note:
|
||||
- * we don't fiddle with with those enter/exit_ca_mode strings
|
||||
- * because we want to retain most of the last screen contents
|
||||
- * as a visual reminder this program is suspended, not ended! */
|
||||
+ * SIGTSTP, SIGTTIN and SIGTTOU */
|
||||
static void sig_paused (int dont_care_sig) {
|
||||
// POSIX.1-2004 async-signal-safe: tcsetattr, tcdrain, raise
|
||||
if (-1 == tcsetattr(STDIN_FILENO, TCSAFLUSH, &Tty_original))
|
||||
error_exit(fmtmk(N_fmt(FAIL_tty_set_fmt), strerror(errno)));
|
||||
if (keypad_local) putp(keypad_local);
|
||||
- putp(tg2(0, Screen_rows));
|
||||
+ if (Cursor_repos) putp(tg2(0, Screen_rows));
|
||||
putp(Cap_curs_norm);
|
||||
#ifndef RMAN_IGNORED
|
||||
putp(Cap_smam);
|
||||
@@ -2120,6 +2120,7 @@ static void fields_utility (void) {
|
||||
int i, key;
|
||||
FLG_t f;
|
||||
|
||||
+ Cursor_repos = 1;
|
||||
spewFI
|
||||
signify_that:
|
||||
putp(Cap_clr_scr);
|
||||
@@ -2180,6 +2181,7 @@ signify_that:
|
||||
break;
|
||||
}
|
||||
} while (key != 'q' && key != kbd_ESC);
|
||||
+ Cursor_repos = 0;
|
||||
#undef unSCRL
|
||||
#undef swapEM
|
||||
#undef spewFI
|
||||
@@ -3768,8 +3770,10 @@ static void whack_terminal (void) {
|
||||
// thanks anyway stdio, but we'll manage buffering at the frame level...
|
||||
setbuffer(stdout, Stdout_buf, sizeof(Stdout_buf));
|
||||
#endif
|
||||
+#ifdef OFF_SCROLLBK
|
||||
// this has the effect of disabling any troublesome scrollback buffer...
|
||||
if (enter_ca_mode) putp(enter_ca_mode);
|
||||
+#endif
|
||||
// and don't forget to ask iokey to initialize his tinfo_tab
|
||||
iokey(0);
|
||||
} // end: whack_terminal
|
||||
diff --git a/top/top.h b/top/top.h
|
||||
index f356798..a8a7357 100644
|
||||
--- a/top/top.h
|
||||
+++ b/top/top.h
|
||||
@@ -41,6 +41,7 @@
|
||||
//#define INSP_SAVEBUF /* preserve 'Insp_buf' contents in a file */
|
||||
//#define INSP_SLIDE_1 /* when scrolling left/right don't move 8 */
|
||||
//#define OFF_HST_HASH /* use BOTH qsort+bsrch vs. hashing scheme */
|
||||
+//#define OFF_SCROLLBK /* disable tty emulators scrollback buffer */
|
||||
//#define OFF_STDIOLBF /* disable our own stdout _IOFBF override */
|
||||
//#define PRETEND2_5_X /* pretend we're linux 2.5.x (for IO-wait) */
|
||||
//#define PRETEND8CPUS /* pretend we're smp with 8 ticsers (sic) */
|
||||
--
|
||||
1.8.1.2
|
||||
|
@ -1,232 +0,0 @@
|
||||
From e5d1a884f4e780aca7f9eaf68a51b967f9b43abf Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Sun, 30 Jun 2013 00:00:00 -0500
|
||||
Subject: [PATCH 1/2] top: refine some miscellaneous signals interrupt stuff
|
||||
|
||||
This commit mostly justs renames a few identifiers but
|
||||
it also will now suppress any end-of-job report if top
|
||||
wasn't ended via the 'q' key convention (i.e. signal).
|
||||
|
||||
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
||||
---
|
||||
top/top.c | 48 +++++++++++++++++++++++++-----------------------
|
||||
top/top.h | 4 ++--
|
||||
2 files changed, 27 insertions(+), 25 deletions(-)
|
||||
|
||||
diff --git a/top/top.c b/top/top.c
|
||||
index cdcf3c0..c1c61dd 100644
|
||||
--- a/top/top.c
|
||||
+++ b/top/top.c
|
||||
@@ -174,7 +174,7 @@ static WIN_t *Curwin;
|
||||
and/or that are simply more efficiently handled as globals
|
||||
[ 'Frames_...' (plural) stuff persists beyond 1 frame ]
|
||||
[ or are used in response to async signals received ! ] */
|
||||
-static volatile int Frames_resize; // time to rebuild all column headers
|
||||
+static volatile int Frames_signal; // time to rebuild all column headers
|
||||
static int Frames_libflags; // PROC_FILLxxx flags
|
||||
static int Frame_maxtask; // last known number of active tasks
|
||||
// ie. current 'size' of proc table
|
||||
@@ -377,7 +377,7 @@ static void bye_bye (const char *str) {
|
||||
at_eoj(); // restore tty in preparation for exit
|
||||
#ifdef ATEOJ_RPTSTD
|
||||
{ proc_t *p;
|
||||
- if (!str && Ttychanged) { fprintf(stderr,
|
||||
+ if (!str && !Frames_signal && Ttychanged) { fprintf(stderr,
|
||||
"\n%s's Summary report:"
|
||||
"\n\tProgram"
|
||||
"\n\t Linux version = %u.%u.%u, %s"
|
||||
@@ -447,7 +447,7 @@ static void bye_bye (const char *str) {
|
||||
|
||||
#ifndef OFF_HST_HASH
|
||||
#ifdef ATEOJ_RPTHSH
|
||||
- if (!str && Ttychanged) {
|
||||
+ if (!str && !Frames_signal && Ttychanged) {
|
||||
int i, j, pop, total_occupied, maxdepth, maxdepth_sav, numdepth
|
||||
, cross_foot, sz = HHASH_SIZ * (unsigned)sizeof(int);
|
||||
int depths[HHASH_SIZ];
|
||||
@@ -588,6 +588,7 @@ static void sig_endpgm (int dont_care_sig) {
|
||||
// POSIX.1-2004 async-signal-safe: sigfillset, sigprocmask
|
||||
sigfillset(&ss);
|
||||
sigprocmask(SIG_BLOCK, &ss, NULL);
|
||||
+ Frames_signal = BREAK_sig;
|
||||
bye_bye(NULL);
|
||||
(void)dont_care_sig;
|
||||
} // end: sig_endpgm
|
||||
@@ -619,7 +620,7 @@ static void sig_paused (int dont_care_sig) {
|
||||
#endif
|
||||
if (keypad_xmit) putp(keypad_xmit);
|
||||
putp(Cursor_state);
|
||||
- Frames_resize = RESIZ_sig;
|
||||
+ Frames_signal = BREAK_sig;
|
||||
(void)dont_care_sig;
|
||||
} // end: sig_paused
|
||||
|
||||
@@ -630,7 +631,7 @@ static void sig_paused (int dont_care_sig) {
|
||||
static void sig_resize (int dont_care_sig) {
|
||||
// POSIX.1-2004 async-signal-safe: tcdrain
|
||||
tcdrain(STDOUT_FILENO);
|
||||
- Frames_resize = RESIZ_sig;
|
||||
+ Frames_signal = BREAK_sig;
|
||||
(void)dont_care_sig;
|
||||
} // end: sig_resize
|
||||
|
||||
@@ -928,12 +929,13 @@ static inline int ioa (struct timespec *ts) {
|
||||
FD_ZERO(&fs);
|
||||
FD_SET(STDIN_FILENO, &fs);
|
||||
|
||||
-#ifndef SIGNALS_LESS // conditional comments are silly, but help in documenting
|
||||
- // hold here until we've got keyboard input, any signal (including SIGWINCH)
|
||||
-#else
|
||||
+#ifdef SIGNALS_LESS // conditional comments are silly, but help in documenting
|
||||
// hold here until we've got keyboard input, any signal except SIGWINCH
|
||||
-#endif
|
||||
// or (optionally) we timeout with nanosecond granularity
|
||||
+#else
|
||||
+ // hold here until we've got keyboard input, any signal (including SIGWINCH)
|
||||
+ // or (optionally) we timeout with nanosecond granularity
|
||||
+#endif
|
||||
rc = pselect(STDIN_FILENO + 1, &fs, NULL, NULL, ts, &Sigwinch_set);
|
||||
|
||||
if (rc < 0) rc = 0;
|
||||
@@ -1263,7 +1265,7 @@ static float get_float (const char *prompt) {
|
||||
float f;
|
||||
|
||||
line = ioline(prompt);
|
||||
- if (!line[0] || Frames_resize) return -1.0;
|
||||
+ if (!line[0] || Frames_signal) return -1.0;
|
||||
// note: we're not allowing negative floats
|
||||
if (strcspn(line, "+,.0123456789")) {
|
||||
show_msg(N_txt(BAD_numfloat_txt));
|
||||
@@ -1284,7 +1286,7 @@ static int get_int (const char *prompt) {
|
||||
int n;
|
||||
|
||||
line = ioline(prompt);
|
||||
- if (Frames_resize) return GET_INT_BAD;
|
||||
+ if (Frames_signal) return GET_INT_BAD;
|
||||
if (!line[0]) return GET_INTNONE;
|
||||
// note: we've got to allow negative ints (renice)
|
||||
if (strcspn(line, "-+0123456789")) {
|
||||
@@ -1822,7 +1824,7 @@ static void adj_geometry (void) {
|
||||
PSU_CLREOS(0);
|
||||
|
||||
fflush(stdout);
|
||||
- Frames_resize = RESIZ_clr;
|
||||
+ Frames_signal = BREAK_off;
|
||||
} // end: adj_geometry
|
||||
|
||||
|
||||
@@ -2134,7 +2136,7 @@ signify_that:
|
||||
display_fields(i, (p != NULL));
|
||||
fflush(stdout);
|
||||
|
||||
- if (Frames_resize) goto signify_that;
|
||||
+ if (Frames_signal) goto signify_that;
|
||||
key = iokey(1);
|
||||
if (key < 1) goto signify_that;
|
||||
|
||||
@@ -3053,7 +3055,7 @@ signify_that:
|
||||
lest repeated <Enter> keys produce immediate re-selection in caller */
|
||||
tcflush(STDIN_FILENO, TCIFLUSH);
|
||||
|
||||
- if (Frames_resize) goto signify_that;
|
||||
+ if (Frames_signal) goto signify_that;
|
||||
key = iokey(1);
|
||||
if (key < 1) goto signify_that;
|
||||
|
||||
@@ -3158,7 +3160,7 @@ signify_that:
|
||||
, pid, p->cmd, p->euser, sels));
|
||||
INSP_MKSL(0, " ");
|
||||
|
||||
- if (Frames_resize) goto signify_that;
|
||||
+ if (Frames_signal) goto signify_that;
|
||||
if (key == INT_MAX) key = iokey(1);
|
||||
if (key < 1) goto signify_that;
|
||||
|
||||
@@ -3903,7 +3905,7 @@ signify_that:
|
||||
putp(Cap_clr_eos);
|
||||
fflush(stdout);
|
||||
|
||||
- if (Frames_resize) goto signify_that;
|
||||
+ if (Frames_signal) goto signify_that;
|
||||
key = iokey(1);
|
||||
if (key < 1) goto signify_that;
|
||||
|
||||
@@ -4135,7 +4137,7 @@ signify_that:
|
||||
putp(Cap_clr_eos);
|
||||
fflush(stdout);
|
||||
|
||||
- if (Frames_resize) goto signify_that;
|
||||
+ if (Frames_signal) goto signify_that;
|
||||
key = iokey(1);
|
||||
if (key < 1) goto signify_that;
|
||||
|
||||
@@ -4151,7 +4153,7 @@ signify_that:
|
||||
, Winstk[2].rc.winname, Winstk[3].rc.winname));
|
||||
putp(Cap_clr_eos);
|
||||
fflush(stdout);
|
||||
- if (Frames_resize || (key = iokey(1)) < 1) {
|
||||
+ if (Frames_signal || (key = iokey(1)) < 1) {
|
||||
adj_geometry();
|
||||
putp(Cap_clr_scr);
|
||||
} else w = win_select(key);
|
||||
@@ -4341,7 +4343,7 @@ static void keys_global (int ch) {
|
||||
if (0 > pid) pid = def;
|
||||
str = ioline(fmtmk(N_fmt(GET_sigs_num_fmt), pid, SIGTERM));
|
||||
if (*str) sig = signal_name_to_number(str);
|
||||
- if (Frames_resize) break;
|
||||
+ if (Frames_signal) break;
|
||||
if (0 < sig && kill(pid, sig))
|
||||
show_msg(fmtmk(N_fmt(FAIL_signals_fmt)
|
||||
, pid, sig, strerror(errno)));
|
||||
@@ -4909,12 +4911,12 @@ static void do_key (int ch) {
|
||||
for (i = 0; i < MAXTBL(key_tab); ++i)
|
||||
if (strchr(key_tab[i].keys, ch)) {
|
||||
key_tab[i].func(ch);
|
||||
- Frames_resize = RESIZ_kbd;
|
||||
+ Frames_signal = BREAK_kbd;
|
||||
putp((Cursor_state = Cap_curs_hide));
|
||||
return;
|
||||
}
|
||||
};
|
||||
- /* Frames_resize above will force a rebuild of all column headers and
|
||||
+ /* Frames_signal above will force a rebuild of all column headers and
|
||||
the PROC_FILLxxx flags. It's NOT simply lazy programming. Here are
|
||||
some keys that COULD require new column headers and/or libproc flags:
|
||||
'A' - likely
|
||||
@@ -5458,7 +5460,7 @@ static void frame_make (void) {
|
||||
int i, scrlins;
|
||||
|
||||
// deal with potential signal(s) since the last time around...
|
||||
- if (Frames_resize)
|
||||
+ if (Frames_signal)
|
||||
zap_fieldstab();
|
||||
|
||||
// whoa either first time or thread/task mode change, (re)prime the pump...
|
||||
@@ -5549,7 +5551,7 @@ int main (int dont_care_argc, char **argv) {
|
||||
produce a screen refresh. in this main loop frame_make
|
||||
assumes responsibility for such refreshes. other logic
|
||||
in contact with users must deal more obliquely with an
|
||||
- interrupt/refresh (hint: Frames_resize + return code)!
|
||||
+ interrupt/refresh (hint: Frames_signal + return code)!
|
||||
|
||||
(everything is perfectly justified plus right margins)
|
||||
(are completely filled, but of course it must be luck)
|
||||
diff --git a/top/top.h b/top/top.h
|
||||
index a8a7357..43d1ebc 100644
|
||||
--- a/top/top.h
|
||||
+++ b/top/top.h
|
||||
@@ -208,9 +208,9 @@ enum scale_enum {
|
||||
SK_Kb, SK_Mb, SK_Gb, SK_Tb, SK_Pb, SK_Eb, SK_SENTINEL
|
||||
};
|
||||
|
||||
- /* Used to manipulate (and document) the Frames_resize states */
|
||||
+ /* Used to manipulate (and document) the Frames_signal states */
|
||||
enum resize_states {
|
||||
- RESIZ_clr, RESIZ_kbd, RESIZ_sig
|
||||
+ BREAK_off = 0, BREAK_kbd, BREAK_sig
|
||||
};
|
||||
|
||||
/* This typedef just ensures consistent 'process flags' handling */
|
||||
--
|
||||
1.8.1.2
|
||||
|
@ -1,42 +0,0 @@
|
||||
From b1f06bdcc9e02f7dbaf1161ad6231c45ea3f9d88 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Tue, 25 Jun 2013 00:00:00 -0500
|
||||
Subject: [PATCH 2/2] library: for atexit() support, fix fileutils for EPIPE
|
||||
|
||||
When fileutils with stream error checking was borrowed
|
||||
from GNU lib, an omission was also propagated where an
|
||||
errno of EPIPE wouldn't be preserved in close_stream()
|
||||
making a test for EPIPE in close_stdout() meaningless.
|
||||
|
||||
This patch corrects such oversight so that an errno of
|
||||
EPIPE no longer produces 'write error' at program end.
|
||||
|
||||
( gnulib provides for optionally ignoring EPIPE, but )
|
||||
( if a program chooses to ignore it, then their code )
|
||||
( appears to suffer from this close_stream oversight )
|
||||
|
||||
Reference(s):
|
||||
. original fileutilis addition
|
||||
commit c7cf98b0e03780f78abe5275c6fb282f71a2369f
|
||||
. bugzilla report
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=976199
|
||||
---
|
||||
lib/fileutils.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/fileutils.c b/lib/fileutils.c
|
||||
index a9ef2ff..1ade3d8 100644
|
||||
--- a/lib/fileutils.c
|
||||
+++ b/lib/fileutils.c
|
||||
@@ -24,7 +24,7 @@ int close_stream(FILE * stream)
|
||||
const int prev_fail = (ferror(stream) != 0);
|
||||
const int fclose_fail = (fclose(stream) != 0);
|
||||
if (prev_fail || (fclose_fail && (some_pending || errno != EBADF))) {
|
||||
- if (!fclose_fail)
|
||||
+ if (!fclose_fail && errno != EPIPE)
|
||||
errno = 0;
|
||||
return EOF;
|
||||
}
|
||||
--
|
||||
1.8.1.2
|
||||
|
@ -1,60 +0,0 @@
|
||||
From eee15b862dd5b051f16c719bf3c974591783a8f8 Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Mon, 1 Jul 2013 00:00:00 -0500
|
||||
Subject: [PATCH 2/2] top: cursor repositioning includes line oriented input
|
||||
|
||||
A recent patch introduced the ability to recognize the
|
||||
need to reposition the cursor at suspension or program
|
||||
end. There remained unmet 1 additional potential need.
|
||||
|
||||
This commit extends that ability to embrace line input
|
||||
so that if a user issues ^Z or ^C while being prompted
|
||||
the resulting shell output will no longer be embedded.
|
||||
|
||||
Reference(s):
|
||||
http://www.freelists.org/post/procps/top-library-miscellaneous-tweaks,7
|
||||
commit 5c974ff44da4fbbb9170dd15bdd81555c62c31a9
|
||||
|
||||
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
||||
---
|
||||
top/top.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/top/top.c b/top/top.c
|
||||
index c1c61dd..138f3ee 100644
|
||||
--- a/top/top.c
|
||||
+++ b/top/top.c
|
||||
@@ -1081,12 +1081,14 @@ static char *ioline (const char *prompt) {
|
||||
static char buf[MEDBUFSIZ];
|
||||
char *p;
|
||||
|
||||
+ Cursor_repos = 1;
|
||||
show_pmt(prompt);
|
||||
memset(buf, '\0', sizeof(buf));
|
||||
ioch(1, buf, sizeof(buf)-1);
|
||||
|
||||
if ((p = strpbrk(buf, ws))) *p = '\0';
|
||||
// note: we DO produce a vaid 'string'
|
||||
+ Cursor_repos = 0;
|
||||
return buf;
|
||||
} // end: ioline
|
||||
|
||||
@@ -1117,6 +1119,7 @@ static char *ioline (const char *prompt) {
|
||||
};
|
||||
static struct lin_s *anchor, *plin;
|
||||
|
||||
+ Cursor_repos = 1;
|
||||
if (!anchor) {
|
||||
anchor = alloc_c(sizeof(struct lin_s));
|
||||
anchor->str = alloc_s(""); // top-of-stack == empty str
|
||||
@@ -1182,6 +1185,7 @@ static char *ioline (const char *prompt) {
|
||||
putp(tg2(beg+pos, Msg_row));
|
||||
} while (key && key != kbd_ENTER && key != kbd_ESC);
|
||||
|
||||
+ Cursor_repos = 0;
|
||||
// weed out duplicates, including empty strings (top-of-stack)...
|
||||
for (i = 0, plin = anchor; ; i++) {
|
||||
#ifdef RECALL_FIXED
|
||||
--
|
||||
1.8.1.2
|
||||
|
@ -1,32 +0,0 @@
|
||||
From 19597fd95e0c8bcb54e4f87a43e20d36016c48cd Mon Sep 17 00:00:00 2001
|
||||
From: Jim Warner <james.warner@comcast.net>
|
||||
Date: Tue, 17 Sep 2013 00:00:00 -0500
|
||||
Subject: [PATCH 2/2] top: restore the lost final newline when in Batch mode
|
||||
|
||||
This patch adds the final newline when exiting 'Batch'
|
||||
mode. Interestingly, it has been missing since release
|
||||
3.3.5 but undetected until the Redhat bugzilla report.
|
||||
|
||||
Reference(s):
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1008674
|
||||
|
||||
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
||||
---
|
||||
top/top.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/top/top.c b/top/top.c
|
||||
index 6f4f728..44bc380 100644
|
||||
--- a/top/top.c
|
||||
+++ b/top/top.c
|
||||
@@ -527,6 +527,7 @@ static void bye_bye (const char *str) {
|
||||
fputs(str, stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
+ if (Batch) putp("\n");
|
||||
exit(EXIT_SUCCESS);
|
||||
} // end: bye_bye
|
||||
|
||||
--
|
||||
1.8.1.2
|
||||
|
@ -1,265 +0,0 @@
|
||||
commit de7b3b9222ab4e2f75db88f0f75b555ab306140b
|
||||
Author: Aristeu Rozanski <arozansk@redhat.com>
|
||||
Date: Fri Apr 12 14:40:27 2013 -0400
|
||||
|
||||
pgrep: introduce support for namespaces
|
||||
|
||||
A PID should be specified with --ns:
|
||||
$ pgrep --ns 12345
|
||||
which will only match the processes which belong to to the same 6
|
||||
namespaces. It is also possible to specify which namespaces to test:
|
||||
$ pgrep --ns 12345 --nslist mnt,net,ipc
|
||||
which will match processes that belong to the same mount, network and
|
||||
IPC namespaces as PID 12345.
|
||||
|
||||
Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
|
||||
|
||||
---
|
||||
Makefile.am | 4 +--
|
||||
include/nsutils.h | 7 +++++
|
||||
lib/nsutils.c | 32 +++++++++++++++++++++++++
|
||||
pgrep.1 | 9 +++++++
|
||||
pgrep.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||
5 files changed, 117 insertions(+), 4 deletions(-)
|
||||
|
||||
--- procps-ng-3.3.8.orig/Makefile.am 2013-05-25 17:39:39.000000000 -0400
|
||||
+++ procps-ng-3.3.8/Makefile.am 2013-09-17 16:57:03.515128029 -0400
|
||||
@@ -89,8 +89,8 @@ else
|
||||
endif
|
||||
|
||||
free_SOURCES = free.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c
|
||||
-pgrep_SOURCES = pgrep.c $(top_srcdir)/lib/fileutils.c
|
||||
-pkill_SOURCES = pgrep.c $(top_srcdir)/lib/fileutils.c
|
||||
+pgrep_SOURCES = pgrep.c $(top_srcdir)/lib/fileutils.c $(top_srcdir)/lib/nsutils.c
|
||||
+pkill_SOURCES = pgrep.c $(top_srcdir)/lib/fileutils.c $(top_srcdir)/lib/nsutils.c
|
||||
pmap_SOURCES = pmap.c $(top_srcdir)/lib/fileutils.c
|
||||
pwdx_SOURCES = pwdx.c $(top_srcdir)/lib/fileutils.c
|
||||
sysctl_SOURCES = sysctl.c $(top_srcdir)/lib/fileutils.c
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ procps-ng-3.3.8/include/nsutils.h 2013-09-17 16:57:03.515128029 -0400
|
||||
@@ -0,0 +1,7 @@
|
||||
+#ifndef PROCPS_NG_NSUTILS
|
||||
+#define PROCPS_NG_NSUTILS
|
||||
+
|
||||
+#include "proc/readproc.h"
|
||||
+int ns_read(pid_t pid, proc_t *ns_task);
|
||||
+
|
||||
+#endif
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ procps-ng-3.3.8/lib/nsutils.c 2013-09-17 16:57:03.515128029 -0400
|
||||
@@ -0,0 +1,32 @@
|
||||
+#include <errno.h>
|
||||
+#include <error.h>
|
||||
+#include <stdio_ext.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/stat.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+#include "proc/readproc.h"
|
||||
+#include "nsutils.h"
|
||||
+
|
||||
+/* we need to fill in only namespace information */
|
||||
+int ns_read(pid_t pid, proc_t *ns_task)
|
||||
+{
|
||||
+ struct stat st;
|
||||
+ char buff[50];
|
||||
+ int i, rc = 0;
|
||||
+
|
||||
+ for (i = 0; i < NUM_NS; i++) {
|
||||
+ snprintf(buff, sizeof(buff), "/proc/%i/ns/%s", pid,
|
||||
+ get_ns_name(i));
|
||||
+ if (stat(buff, &st)) {
|
||||
+ if (errno != ENOENT)
|
||||
+ rc = errno;
|
||||
+ ns_task->ns[i] = 0;
|
||||
+ continue;
|
||||
+ }
|
||||
+ ns_task->ns[i] = st.st_ino;
|
||||
+ }
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
--- procps-ng-3.3.8.orig/pgrep.1 2013-05-25 17:39:40.000000000 -0400
|
||||
+++ procps-ng-3.3.8/pgrep.1 2013-09-17 16:57:03.516128042 -0400
|
||||
@@ -146,6 +146,15 @@ than
|
||||
\fB\-L\fR, \fB\-\-logpidfile\fR
|
||||
Fail if pidfile (see -F) not locked.
|
||||
.TP
|
||||
+\fB\-\-ns \fIpid\fP
|
||||
+Match processes that belong to the same namespaces. Required to run as
|
||||
+root to match processes from other users. See \-\-nslist for how to limit
|
||||
+which namespaces to match.
|
||||
+.TP
|
||||
+\fB\-\-nslist \fIname\fP,...
|
||||
+Match only the provided namespaces. Available namespaces:
|
||||
+ipc, mnt, net, pid, user,uts.
|
||||
+.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Display version information and exit.
|
||||
.TP
|
||||
--- procps-ng-3.3.8.orig/pgrep.c 2013-05-25 17:39:40.000000000 -0400
|
||||
+++ procps-ng-3.3.8/pgrep.c 2013-09-17 16:58:18.439105071 -0400
|
||||
@@ -46,6 +46,7 @@ #define CMDSTRSIZE 4096
|
||||
|
||||
#include "c.h"
|
||||
#include "fileutils.h"
|
||||
+#include "nsutils.h"
|
||||
#include "nls.h"
|
||||
#include "xalloc.h"
|
||||
#include "proc/readproc.h"
|
||||
@@ -76,6 +77,7 @@ static int opt_lock = 0;
|
||||
static int opt_case = 0;
|
||||
static int opt_echo = 0;
|
||||
static int opt_threads = 0;
|
||||
+static pid_t opt_ns_pid = 0;
|
||||
|
||||
static const char *opt_delim = "\n";
|
||||
static struct el *opt_pgrp = NULL;
|
||||
@@ -86,9 +88,13 @@ static struct el *opt_sid = NULL;
|
||||
static struct el *opt_term = NULL;
|
||||
static struct el *opt_euid = NULL;
|
||||
static struct el *opt_ruid = NULL;
|
||||
+static struct el *opt_nslist = NULL;
|
||||
static char *opt_pattern = NULL;
|
||||
static char *opt_pidfile = NULL;
|
||||
|
||||
+/* by default, all namespaces will be checked */
|
||||
+static int ns_flags = 0x3f;
|
||||
+
|
||||
static int __attribute__ ((__noreturn__)) usage(int opt)
|
||||
{
|
||||
int err = (opt == '?');
|
||||
@@ -121,7 +127,12 @@ if (i_am_pkill == 0) {
|
||||
" -U, --uid <id,...> match by real IDs\n"
|
||||
" -x, --exact match exactly with the command name\n"
|
||||
" -F, --pidfile <file> read PIDs from file\n"
|
||||
- " -L, --logpidfile fail if PID file is not locked\n"), fp);
|
||||
+ " -L, --logpidfile fail if PID file is not locked\n"
|
||||
+ " --ns <pid> match the processes that belong to the same\n"
|
||||
+ " namespace as <pid>\n"
|
||||
+ " --nslist <ns,...> list which namespaces will be considered for\n"
|
||||
+ " the --ns option.\n"
|
||||
+ " Available namespaces: ipc, mnt, net, pid, user, uts\n"), fp);
|
||||
fputs(USAGE_SEPARATOR, fp);
|
||||
fputs(USAGE_HELP, fp);
|
||||
fputs(USAGE_VERSION, fp);
|
||||
@@ -320,6 +331,20 @@ static int conv_str (const char *restric
|
||||
}
|
||||
|
||||
|
||||
+static int conv_ns (const char *restrict name, struct el *restrict e)
|
||||
+{
|
||||
+ int rc = conv_str(name, e);
|
||||
+ int id;
|
||||
+
|
||||
+ ns_flags = 0;
|
||||
+ id = get_ns_id(name);
|
||||
+ if (id == -1)
|
||||
+ return 0;
|
||||
+ ns_flags |= (1 << id);
|
||||
+
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
static int match_numlist (long value, const struct el *restrict list)
|
||||
{
|
||||
int found = 0;
|
||||
@@ -350,6 +375,21 @@ for (i = list[0].num; i > 0; i--) {
|
||||
return found;
|
||||
}
|
||||
|
||||
+static int match_ns (const proc_t *task, const proc_t *ns_task)
|
||||
+{
|
||||
+ int found = 1;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < NUM_NS; i++) {
|
||||
+ if (ns_flags & (1 << i)) {
|
||||
+ if (task->ns[i] != ns_task->ns[i])
|
||||
+ found = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return found;
|
||||
+}
|
||||
+
|
||||
static void output_numlist (const struct el *restrict list, int num)
|
||||
{
|
||||
int i;
|
||||
@@ -386,6 +426,8 @@ int flags = 0;
|
||||
flags |= PROC_FILLSTAT;
|
||||
if (!(flags & PROC_FILLSTAT))
|
||||
flags |= PROC_FILLSTATUS; /* FIXME: need one, and PROC_FILLANY broken */
|
||||
+ if (opt_ns_pid)
|
||||
+ flags |= PROC_FILLNS;
|
||||
if (opt_euid && !opt_negate) {
|
||||
int num = opt_euid[0].num;
|
||||
int i = num;
|
||||
@@ -442,6 +484,7 @@ int size = 0;
|
||||
char cmdline[CMDSTRSIZE];
|
||||
char cmdsearch[CMDSTRSIZE];
|
||||
char cmdoutput[CMDSTRSIZE];
|
||||
+ proc_t ns_task;
|
||||
|
||||
ptp = do_openproc();
|
||||
preg = do_regcomp();
|
||||
@@ -451,6 +494,11 @@ else saved_start_time = ~0ULL;
|
||||
|
||||
if (opt_newest) saved_pid = 0;
|
||||
if (opt_oldest) saved_pid = INT_MAX;
|
||||
+ if (opt_ns_pid && ns_read(opt_ns_pid, &ns_task)) {
|
||||
+ fputs(_("Error reading reference namespace information\n"),
|
||||
+ stderr);
|
||||
+ exit (EXIT_FATAL);
|
||||
+ }
|
||||
|
||||
memset(&task, 0, sizeof (task));
|
||||
while(readproc(ptp, &task)) {
|
||||
@@ -476,6 +524,8 @@ match = 0;
|
||||
match = 0;
|
||||
else if (opt_sid && ! match_numlist (task.session, opt_sid))
|
||||
match = 0;
|
||||
+ else if (opt_ns_pid && ! match_ns (&task, &ns_task))
|
||||
+ match = 0;
|
||||
else if (opt_term) {
|
||||
if (task.tty == 0) {
|
||||
match = 0;
|
||||
@@ -622,7 +672,9 @@ static void parse_opts (int argc, char *
|
||||
int criteria_count = 0;
|
||||
|
||||
enum {
|
||||
- SIGNAL_OPTION = CHAR_MAX + 1
|
||||
+ SIGNAL_OPTION = CHAR_MAX + 1,
|
||||
+ NS_OPTION,
|
||||
+ NSLIST_OPTION,
|
||||
};
|
||||
static const struct option longopts[] = {
|
||||
{"signal", required_argument, NULL, SIGNAL_OPTION},
|
||||
@@ -646,6 +698,8 @@ int criteria_count = 0;
|
||||
{"pidfile", required_argument, NULL, 'F'},
|
||||
{"logpidfile", no_argument, NULL, 'L'},
|
||||
{"echo", no_argument, NULL, 'e'},
|
||||
+ {"ns", required_argument, NULL, NS_OPTION},
|
||||
+ {"nslist", required_argument, NULL, NSLIST_OPTION},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"version", no_argument, NULL, 'V'},
|
||||
{NULL, 0, NULL, 0}
|
||||
@@ -792,6 +846,17 @@ case 'l': /* Solaris: long output fo
|
||||
break;
|
||||
/* case 'z': / * Solaris: match by zone ID * /
|
||||
* break; */
|
||||
+ case NS_OPTION:
|
||||
+ opt_ns_pid = atoi(optarg);
|
||||
+ if (opt_ns_pid == 0)
|
||||
+ usage (opt);
|
||||
+ ++criteria_count;
|
||||
+ break;
|
||||
+ case NSLIST_OPTION:
|
||||
+ opt_nslist = split_list (optarg, conv_ns);
|
||||
+ if (opt_nslist == NULL)
|
||||
+ usage (opt);
|
||||
+ break;
|
||||
case 'h':
|
||||
usage (opt);
|
||||
break;
|
@ -1,325 +0,0 @@
|
||||
commit a01ee3c0b32d4c39aa83066ed61103343469527e
|
||||
Author: Aristeu Rozanski <arozansk@redhat.com>
|
||||
Date: Mon Apr 8 15:03:13 2013 -0400
|
||||
|
||||
procps: add support for linux namespaces
|
||||
|
||||
Each process in Linux has a /proc/<pid>/ns directory which contains
|
||||
symbolic links to pipes that identify which namespaces that process
|
||||
belongs to. This patch adds support for ps to display that information
|
||||
optionally.
|
||||
|
||||
Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
|
||||
|
||||
---
|
||||
proc/libprocps.sym | 2 +
|
||||
proc/readproc.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
proc/readproc.h | 15 +++++++++++++
|
||||
ps/output.c | 38 ++++++++++++++++++++++++++++++++++
|
||||
ps/ps.1 | 24 +++++++++++++++++++++
|
||||
5 files changed, 137 insertions(+)
|
||||
|
||||
--- procps-ng-3.3.8.orig/proc/libprocps.sym 2013-05-25 17:39:40.000000000 -0400
|
||||
+++ procps-ng-3.3.8/proc/libprocps.sym 2013-09-17 16:09:45.496846630 -0400
|
||||
@@ -11,6 +11,8 @@ global:
|
||||
escaped_copy;
|
||||
free_slabinfo;
|
||||
freeproc;
|
||||
+ get_ns_id;
|
||||
+ get_ns_name;
|
||||
get_pid_digits;
|
||||
get_slabinfo;
|
||||
getbtime;
|
||||
--- procps-ng-3.3.8.orig/proc/readproc.c 2013-05-25 17:39:40.000000000 -0400
|
||||
+++ procps-ng-3.3.8/proc/readproc.c 2013-09-17 16:09:45.498846654 -0400
|
||||
@@ -457,6 +457,51 @@ static void oomadj2proc(const char* S, p
|
||||
#endif
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
+static ino_t _ns2proc(unsigned pid, const char *ns)
|
||||
+{
|
||||
+ struct stat s;
|
||||
+ char filename[40];
|
||||
+
|
||||
+ snprintf(filename, sizeof(filename), "/proc/%i/ns/%s", pid, ns);
|
||||
+
|
||||
+ if (stat(filename, &s) == -1)
|
||||
+ return 0;
|
||||
+
|
||||
+ return s.st_ino;
|
||||
+}
|
||||
+
|
||||
+static const char *ns_names[] = {
|
||||
+ [IPCNS] = "ipc",
|
||||
+ [MNTNS] = "mnt",
|
||||
+ [NETNS] = "net",
|
||||
+ [PIDNS] = "pid",
|
||||
+ [USERNS] = "user",
|
||||
+ [UTSNS] = "uts",
|
||||
+};
|
||||
+
|
||||
+const char *get_ns_name(int id) {
|
||||
+ if (id >= NUM_NS)
|
||||
+ return NULL;
|
||||
+ return ns_names[id];
|
||||
+}
|
||||
+
|
||||
+int get_ns_id(const char *name) {
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < NUM_NS; i++)
|
||||
+ if (!strcmp(ns_names[i], name))
|
||||
+ return i;
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+static void ns2proc(proc_t *restrict P) {
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < NUM_NS; i++)
|
||||
+ P->ns[i] = _ns2proc(P->tgid, ns_names[i]);
|
||||
+}
|
||||
+///////////////////////////////////////////////////////////////////////
|
||||
+
|
||||
|
||||
// Reads /proc/*/stat files, being careful not to trip over processes with
|
||||
// names like ":-) 1 2 3 4 5 6".
|
||||
@@ -757,6 +802,7 @@ static struct utlbuf_s ub = { NULL,
|
||||
static struct stat sb; // stat() buffer
|
||||
char *restrict const path = PT->path;
|
||||
unsigned flags = PT->flags;
|
||||
+ int i;
|
||||
|
||||
if (unlikely(stat(path, &sb) == -1)) /* no such dirent (anymore) */
|
||||
goto next_proc;
|
||||
@@ -844,6 +890,12 @@ p->wchan = (KLONG)~0ull;
|
||||
}
|
||||
#endif
|
||||
|
||||
+ if (unlikely(flags & PROC_FILLNS)) // read /proc/#/ns/*
|
||||
+ ns2proc(p);
|
||||
+ else
|
||||
+ for (i = 0; i < NUM_NS; i++)
|
||||
+ p->ns[i] = 0;
|
||||
+
|
||||
return p;
|
||||
next_proc:
|
||||
return NULL;
|
||||
@@ -862,6 +914,7 @@ static proc_t* simple_readtask(PROCTAB *
|
||||
static struct utlbuf_s ub = { NULL, 0 }; // buf for stat,statm,status
|
||||
static struct stat sb; // stat() buffer
|
||||
unsigned flags = PT->flags;
|
||||
+ int i;
|
||||
|
||||
if (unlikely(stat(path, &sb) == -1)) /* no such dirent (anymore) */
|
||||
goto next_task;
|
||||
@@ -974,6 +1027,11 @@ status2proc(ub.buf, t, 0);
|
||||
oomadj2proc(ub.buf, t);
|
||||
}
|
||||
#endif
|
||||
+ if (unlikely(flags & PROC_FILLNS))
|
||||
+ ns2proc(t);
|
||||
+ else
|
||||
+ for (i = 0; i < NUM_NS; i++)
|
||||
+ t->ns[i] = 0;
|
||||
|
||||
return t;
|
||||
next_task:
|
||||
--- procps-ng-3.3.8.orig/proc/readproc.h 2013-05-25 17:39:40.000000000 -0400
|
||||
+++ procps-ng-3.3.8/proc/readproc.h 2013-09-17 16:09:45.499846666 -0400
|
||||
@@ -31,6 +31,18 @@ EXTERN_C_BEGIN
|
||||
// neither tgid nor tid seemed correct. (in other words, FIXME)
|
||||
#define XXXID tid
|
||||
|
||||
+#define NUM_NS 6
|
||||
+enum ns_type {
|
||||
+ IPCNS = 0,
|
||||
+ MNTNS,
|
||||
+ NETNS,
|
||||
+ PIDNS,
|
||||
+ USERNS,
|
||||
+ UTSNS
|
||||
+};
|
||||
+extern const char *get_ns_name(int id);
|
||||
+extern int get_ns_id(const char *name);
|
||||
+
|
||||
// Basic data structure which holds all information we can get about a process.
|
||||
// (unless otherwise specified, fields are read from /proc/#/stat)
|
||||
//
|
||||
@@ -157,6 +169,8 @@ nlwp, // stat,status number of thr
|
||||
oom_score, // oom_score (badness for OOM killer)
|
||||
oom_adj; // oom_adj (adjustment to OOM score)
|
||||
#endif
|
||||
+ ino_t
|
||||
+ ns[NUM_NS]; // ns/* inode number of /proc/<pid>/ns/*
|
||||
} proc_t;
|
||||
|
||||
// PROCTAB: data structure holding the persistent information readproc needs
|
||||
@@ -266,6 +280,7 @@ #define PROC_FILLARG 0x0100 // a
|
||||
#define PROC_FILLCGROUP 0x0200 // alloc and fill in `cgroup`
|
||||
#define PROC_FILLSUPGRP 0x0400 // resolve supplementary group id -> group name
|
||||
#define PROC_FILLOOM 0x0800 // fill in proc_t oom_score and oom_adj
|
||||
+#define PROC_FILLNS 0x8000 // fill in proc_t namespace information
|
||||
|
||||
#define PROC_LOOSE_TASKS 0x2000 // treat threads as if they were processes
|
||||
|
||||
--- procps-ng-3.3.8.orig/ps/output.c 2013-09-17 16:08:53.000000000 -0400
|
||||
+++ procps-ng-3.3.8/ps/output.c 2013-09-17 16:10:41.087532129 -0400
|
||||
@@ -139,6 +139,13 @@ static int sr_ ## NAME (const proc_t* P,
|
||||
return 0; \
|
||||
}
|
||||
|
||||
+#define CMP_NS(NAME, ID) \
|
||||
+static int sr_ ## NAME (const proc_t* P, const proc_t* Q) { \
|
||||
+ if (P->ns[ID] < Q->ns[ID]) return -1; \
|
||||
+ if (P->ns[ID] > Q->ns[ID]) return 1; \
|
||||
+ return 0; \
|
||||
+}
|
||||
+
|
||||
CMP_INT(rtprio)
|
||||
CMP_SMALL(sched)
|
||||
CMP_INT(cutime)
|
||||
@@ -216,6 +223,13 @@ CMP_SMALL(state)
|
||||
CMP_COOKED_TIME(time)
|
||||
CMP_COOKED_TIME(etime)
|
||||
|
||||
+CMP_NS(ipcns, IPCNS);
|
||||
+CMP_NS(mntns, MNTNS);
|
||||
+CMP_NS(netns, NETNS);
|
||||
+CMP_NS(pidns, PIDNS);
|
||||
+CMP_NS(userns, USERNS);
|
||||
+CMP_NS(utsns, UTSNS);
|
||||
+
|
||||
/* approximation to: kB of address space that could end up in swap */
|
||||
static int sr_swapable(const proc_t* P, const proc_t* Q) {
|
||||
unsigned long p_swapable = P->vm_data + P->vm_stack;
|
||||
@@ -1279,6 +1293,23 @@ outbuf[1] = '\0';
|
||||
}
|
||||
|
||||
#endif
|
||||
+
|
||||
+/************************ Linux namespaces ******************************/
|
||||
+
|
||||
+#define _pr_ns(NAME, ID)\
|
||||
+static int pr_##NAME(char *restrict const outbuf, const proc_t *restrict const pp) {\
|
||||
+ if (pp->ns[ID])\
|
||||
+ return snprintf(outbuf, COLWID, "%li", pp->ns[ID]);\
|
||||
+ else\
|
||||
+ return snprintf(outbuf, COLWID, "-");\
|
||||
+}
|
||||
+_pr_ns(ipcns, IPCNS);
|
||||
+_pr_ns(mntns, MNTNS);
|
||||
+_pr_ns(netns, NETNS);
|
||||
+_pr_ns(pidns, PIDNS);
|
||||
+_pr_ns(userns, USERNS);
|
||||
+_pr_ns(utsns, UTSNS);
|
||||
+
|
||||
/****************** FLASK & seLinux security stuff **********************/
|
||||
// move the bulk of this to libproc sometime
|
||||
|
||||
@@ -1439,6 +1470,7 @@ static const char *const vals[] = {"tt
|
||||
#define USR PROC_FILLUSR /* uid_t -> user names */
|
||||
#define GRP PROC_FILLGRP /* gid_t -> group names */
|
||||
#define WCH PROC_FILLWCHAN /* do WCHAN lookup */
|
||||
+#define NS PROC_FILLNS /* read namespace information */
|
||||
|
||||
#define SGRP PROC_FILLSTATUS | PROC_FILLSUPGRP /* supgid -> supgrp (names) */
|
||||
#define CGRP PROC_FILLCGROUP | PROC_EDITCGRPCVT /* read cgroup */
|
||||
@@ -1527,6 +1559,7 @@ {"ignored", "IGNORED", pr_sigignore,sr
|
||||
{"inblk", "INBLK", pr_nop, sr_nop, 5, 0, BSD, AN|RIGHT}, /*inblock*/
|
||||
{"inblock", "INBLK", pr_nop, sr_nop, 5, 0, DEC, AN|RIGHT}, /*inblk*/
|
||||
{"intpri", "PRI", pr_opri, sr_priority, 3, 0, HPU, TO|RIGHT},
|
||||
+{"ipcns", "IPCNS", pr_ipcns, sr_ipcns, 10, NS, LNX, ET|RIGHT},
|
||||
{"jid", "JID", pr_nop, sr_nop, 1, 0, SGI, PO|RIGHT},
|
||||
{"jobc", "JOBC", pr_nop, sr_nop, 4, 0, XXX, AN|RIGHT},
|
||||
{"ktrace", "KTRACE", pr_nop, sr_nop, 8, 0, BSD, AN|RIGHT},
|
||||
@@ -1559,9 +1592,11 @@ {"maj_flt", "MAJFL", pr_majflt, sr
|
||||
{"majflt", "MAJFLT", pr_majflt, sr_maj_flt, 6, 0, XXX, AN|RIGHT},
|
||||
{"min_flt", "MINFL", pr_minflt, sr_min_flt, 6, 0, LNX, AN|RIGHT},
|
||||
{"minflt", "MINFLT", pr_minflt, sr_min_flt, 6, 0, XXX, AN|RIGHT},
|
||||
+{"mntns", "MNTNS", pr_mntns, sr_mntns, 10, NS, LNX, ET|RIGHT},
|
||||
{"msgrcv", "MSGRCV", pr_nop, sr_nop, 6, 0, XXX, AN|RIGHT},
|
||||
{"msgsnd", "MSGSND", pr_nop, sr_nop, 6, 0, XXX, AN|RIGHT},
|
||||
{"mwchan", "MWCHAN", pr_nop, sr_nop, 6, WCH, BSD, TO|WCHAN}, /* mutex (FreeBSD) */
|
||||
+{"netns", "NETNS", pr_netns, sr_netns, 10, NS, LNX, ET|RIGHT},
|
||||
{"ni", "NI", pr_nice, sr_nice, 3, 0, BSD, TO|RIGHT}, /*nice*/
|
||||
{"nice", "NI", pr_nice, sr_nice, 3, 0, U98, TO|RIGHT}, /*ni*/
|
||||
{"nivcsw", "IVCSW", pr_nop, sr_nop, 5, 0, XXX, AN|RIGHT},
|
||||
@@ -1586,6 +1621,7 @@ {"pending", "PENDING", pr_sig, sr
|
||||
{"pgid", "PGID", pr_pgid, sr_pgrp, 5, 0, U98, PO|PIDMAX|RIGHT},
|
||||
{"pgrp", "PGRP", pr_pgid, sr_pgrp, 5, 0, LNX, PO|PIDMAX|RIGHT},
|
||||
{"pid", "PID", pr_procs, sr_procs, 5, 0, U98, PO|PIDMAX|RIGHT},
|
||||
+{"pidns", "PIDNS", pr_pidns, sr_pidns, 10, NS, LNX, ET|RIGHT},
|
||||
{"pmem", "%MEM", pr_pmem, sr_rss, 4, 0, XXX, PO|RIGHT}, /*%mem*/
|
||||
{"poip", "-", pr_nop, sr_nop, 1, 0, BSD, AN|RIGHT},
|
||||
{"policy", "POL", pr_class, sr_sched, 3, 0, DEC, TO|LEFT},
|
||||
@@ -1693,6 +1729,7 @@ {"unit", "UNIT", pr_sd_unit, sr
|
||||
{"upr", "UPR", pr_nop, sr_nop, 3, 0, BSD, TO|RIGHT}, /*usrpri*/
|
||||
{"uprocp", "UPROCP", pr_nop, sr_nop, 8, 0, BSD, AN|RIGHT},
|
||||
{"user", "USER", pr_euser, sr_euser, 8, USR, U98, ET|USER}, /* BSD n forces this to UID */
|
||||
+{"userns", "USERNS", pr_userns, sr_userns, 10, NS, LNX, ET|RIGHT},
|
||||
{"usertime", "USER", pr_nop, sr_nop, 4, 0, DEC, ET|RIGHT},
|
||||
{"usrpri", "UPR", pr_nop, sr_nop, 3, 0, DEC, TO|RIGHT}, /*upr*/
|
||||
{"util", "C", pr_c, sr_pcpu, 2, 0, SGI, ET|RIGHT}, // not sure about "C"
|
||||
@@ -1700,6 +1737,7 @@ {"utime", "UTIME", pr_nop, sr
|
||||
#ifdef WITH_SYSTEMD
|
||||
{"uunit", "UUNIT", pr_sd_uunit, sr_nop, 31, 0, LNX, ET|LEFT},
|
||||
#endif
|
||||
+{"utsns", "UTSNS", pr_utsns, sr_utsns, 10, NS, LNX, ET|RIGHT},
|
||||
{"vm_data", "DATA", pr_nop, sr_vm_data, 5, 0, LNx, PO|RIGHT},
|
||||
{"vm_exe", "EXE", pr_nop, sr_vm_exe, 5, 0, LNx, PO|RIGHT},
|
||||
{"vm_lib", "LIB", pr_nop, sr_vm_lib, 5, 0, LNx, PO|RIGHT},
|
||||
--- procps-ng-3.3.8.orig/ps/ps.1 2013-05-25 17:39:40.000000000 -0400
|
||||
+++ procps-ng-3.3.8/ps/ps.1 2013-09-17 16:11:12.942925254 -0400
|
||||
@@ -1299,6 +1299,10 @@ format is displayed. (alias
|
||||
.BR sig_ignore , \ sigignore ).
|
||||
T}
|
||||
|
||||
+ipcns IPCNS T{
|
||||
+Unique inode number describing the namespace the process belongs to. See namespaces(7).
|
||||
+T}
|
||||
+
|
||||
label LABEL T{
|
||||
security label, most commonly used for SELinux context data. This is for
|
||||
the
|
||||
@@ -1335,6 +1339,14 @@ min_flt MINFLT T{
|
||||
The number of minor page faults that have occurred with this process.
|
||||
T}
|
||||
|
||||
+mntns MNTNS T{
|
||||
+Unique inode number describing the namespace the process belongs to. See namespaces(7).
|
||||
+T}
|
||||
+
|
||||
+netns NETNS T{
|
||||
+Unique inode number describing the namespace the process belongs to. See namespaces(7).
|
||||
+T}
|
||||
+
|
||||
ni NI T{
|
||||
nice value. This ranges from 19 (nicest) to \-20 (not nice to others),
|
||||
see
|
||||
@@ -1403,6 +1415,10 @@ a number representing the process ID (al
|
||||
.BR tgid ).
|
||||
T}
|
||||
|
||||
+pidns PIDNS T{
|
||||
+Unique inode number describing the namespace the process belongs to. See namespaces(7).
|
||||
+T}
|
||||
+
|
||||
pmem %MEM T{
|
||||
see
|
||||
.BR %mem .
|
||||
@@ -1739,6 +1755,14 @@ uunit UUNIT T{
|
||||
displays systemd user unit which a process belongs to.
|
||||
T}
|
||||
|
||||
+userns USERNS T{
|
||||
+Unique inode number describing the namespace the process belongs to. See namespaces(7).
|
||||
+T}
|
||||
+
|
||||
+utsns UTSNS T{
|
||||
+Unique inode number describing the namespace the process belongs to. See namespaces(7).
|
||||
+T}
|
||||
+
|
||||
vsize VSZ T{
|
||||
see
|
||||
.BR vsz .
|
@ -1,28 +0,0 @@
|
||||
commit e2242cb943c620599913db3a68ccba06fa07ac36
|
||||
Author: Jim Warner <james.warner@comcast.net>
|
||||
Date: Wed Sep 11 09:11:13 2013 -0500
|
||||
|
||||
build-sys: fix the fatal 'make dist' error for nsutils
|
||||
|
||||
While a 'make dist' appeared to work fine without this
|
||||
patch, the nsutils.h file was missing from the include
|
||||
subdirectory. Thus the tarball could not support make.
|
||||
|
||||
Reference(s):
|
||||
http://gitorious.org/procps/procps/merge_requests/13
|
||||
commit dd6f24dbed12e95235b3df49e550b5039e74e6d8
|
||||
|
||||
Signed-off-by: Jim Warner <james.warner@comcast.net>
|
||||
|
||||
diff --git a/include/Makefile.am b/include/Makefile.am
|
||||
index c511513..fee45ca 100644
|
||||
--- a/include/Makefile.am
|
||||
+++ b/include/Makefile.am
|
||||
@@ -2,6 +2,7 @@ dist_noinst_HEADERS = \
|
||||
c.h \
|
||||
fileutils.h \
|
||||
nls.h \
|
||||
+ nsutils.h \
|
||||
rpmatch.h \
|
||||
strutils.h \
|
||||
xalloc.h
|
@ -1,73 +0,0 @@
|
||||
diff --git a/sysctl.8 b/sysctl.8
|
||||
index d57ecd1..faf2255 100644
|
||||
--- a/sysctl.8
|
||||
+++ b/sysctl.8
|
||||
@@ -92,7 +92,7 @@ Load settings from all system configuration files.
|
||||
.br
|
||||
/etc/sysctl.conf
|
||||
.TP
|
||||
-\fB\-\-pattern\fR \fIpattern\fR
|
||||
+\fB\-r\fR, \fB\-\-pattern\fR \fIpattern\fR
|
||||
Only apply settings that match
|
||||
.IR pattern .
|
||||
The
|
||||
diff --git a/w.1 b/w.1
|
||||
index 5b2b264..7537f1d 100644
|
||||
--- a/w.1
|
||||
+++ b/w.1
|
||||
@@ -49,7 +49,7 @@ field is shown by default.
|
||||
\fB\-\-help\fR
|
||||
Display help text and exit.
|
||||
.TP
|
||||
-\fB\-\-ip\-addr\fR
|
||||
+\fB\-i\fR, \fB\-\-ip\-addr\fR
|
||||
Display IP address instead of hostname for \fBfrom\fR field.
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
diff --git a/w.c b/w.c
|
||||
index fee9308..c80e117 100644
|
||||
--- a/w.c
|
||||
+++ b/w.c
|
||||
@@ -475,9 +475,10 @@ int main(int argc, char **argv)
|
||||
static const struct option longopts[] = {
|
||||
{"no-header", no_argument, NULL, 'h'},
|
||||
{"no-current", no_argument, NULL, 'u'},
|
||||
- {"sort", no_argument, NULL, 's'},
|
||||
+ {"short", no_argument, NULL, 's'},
|
||||
{"from", no_argument, NULL, 'f'},
|
||||
{"old-style", no_argument, NULL, 'o'},
|
||||
+ {"ip-addr", no_argument, NULL, 'i'},
|
||||
{"help", no_argument, NULL, HELP_OPTION},
|
||||
{"version", no_argument, NULL, 'V'},
|
||||
{NULL, 0, NULL, 0}
|
||||
diff --git a/top/top.1 b/top/top.1
|
||||
index 0a753a8..bfe8ae7 100644
|
||||
--- a/top/top.1
|
||||
+++ b/top/top.1
|
||||
@@ -359,7 +359,7 @@ A pid value of zero will be treated as the process id of the \*(We program
|
||||
itself once it is running.
|
||||
|
||||
This is a \*(CO only and should you wish to return to normal operation,
|
||||
-it is not necessary to quit and and restart \*(We \*(Em just issue any
|
||||
+it is not necessary to quit and restart \*(We \*(Em just issue any
|
||||
of these \*(CIs: '=', 'u' or 'U'.
|
||||
|
||||
The 'p', 'u' and 'U' \*(COs are mutually exclusive.
|
||||
@@ -757,7 +757,7 @@ of a second.
|
||||
The process group ID of the foreground process for the connected tty,
|
||||
or \-1 if a process is not connected to a terminal.
|
||||
By convention, this value equals the process ID (\*(Xa PID) of the
|
||||
-the process group leader (\*(Xa PGRP).
|
||||
+process group leader (\*(Xa PGRP).
|
||||
|
||||
.TP 4
|
||||
32.\fB TTY \*(Em Controlling Tty \fR
|
||||
@@ -1340,7 +1340,7 @@ no processes will be shown.
|
||||
Prepending an exclamation point ('!') to the user id or name instucts top
|
||||
to display only processes with users not matching the one provided.
|
||||
|
||||
-Different \*(TWs can can be used to filter different users.
|
||||
+Different \*(TWs can be used to filter different users.
|
||||
Later, if you wish to monitor all users again in the \*(CW, re-issue this
|
||||
command but just press <Enter> at the prompt.
|
||||
|
@ -1,38 +0,0 @@
|
||||
diff --git a/free.1 b/free.1
|
||||
index f7c2313..1e8e7ef 100644
|
||||
--- a/free.1
|
||||
+++ b/free.1
|
||||
@@ -11,8 +11,11 @@ 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
|
||||
-should be ignored; it is obsolete.
|
||||
+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.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-b\fR, \fB\-\-bytes\fR
|
||||
diff --git a/proc/sysinfo.c b/proc/sysinfo.c
|
||||
index 15cdb83..8e4aca2 100644
|
||||
--- a/proc/sysinfo.c
|
||||
+++ b/proc/sysinfo.c
|
||||
@@ -629,13 +629,14 @@ 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}, // important, but now gone!
|
||||
+ {"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}, // sharing the output variable with obsolete MemShared (kernel 2.6 and later)
|
||||
{"Slab", &kb_slab}, // kB version of vmstat nr_slab
|
||||
{"SwapCached", &kb_swap_cached},
|
||||
{"SwapFree", &kb_swap_free}, // important
|
@ -1,48 +0,0 @@
|
||||
diff -Naur procps-ng-3.3.8.orig/configure.ac procps-ng-3.3.8/configure.ac
|
||||
--- procps-ng-3.3.8.orig/configure.ac 2013-05-25 23:39:39.000000000 +0200
|
||||
+++ procps-ng-3.3.8/configure.ac 2013-08-06 19:53:49.595654086 +0200
|
||||
@@ -111,6 +111,14 @@
|
||||
AC_DEFINE([WITH_WATCH8BIT], [1], [Enable 8 bit clean watch])
|
||||
fi
|
||||
|
||||
+AC_ARG_ENABLE([libselinux],
|
||||
+ AS_HELP_STRING([--enable-libselinux], [enable libselinux]),
|
||||
+ [enable_libselinux=$enableval],
|
||||
+ [enable_libselinux="no"])
|
||||
+if test "$enable_libselinux" = "yes"; then
|
||||
+ AC_DEFINE([ENABLE_LIBSELINUX], [1], [Enable libselinux])
|
||||
+fi
|
||||
+
|
||||
# Optional packages - AC_ARG_WITH
|
||||
AC_ARG_WITH([ncurses],
|
||||
AS_HELP_STRING([--without-ncurses], [build only applications not needing ncurses]),
|
||||
diff -Naur procps-ng-3.3.8.orig/ps/output.c procps-ng-3.3.8/ps/output.c
|
||||
--- procps-ng-3.3.8.orig/ps/output.c 2013-05-25 23:39:40.000000000 +0200
|
||||
+++ procps-ng-3.3.8/ps/output.c 2013-08-06 19:55:32.477650664 +0200
|
||||
@@ -1282,6 +1282,8 @@
|
||||
/****************** FLASK & seLinux security stuff **********************/
|
||||
// move the bulk of this to libproc sometime
|
||||
|
||||
+#if !ENABLE_LIBSELINUX
|
||||
+
|
||||
static int pr_context(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||
char filename[48];
|
||||
size_t len;
|
||||
@@ -1310,7 +1312,8 @@
|
||||
return 1;
|
||||
}
|
||||
|
||||
-#if 0
|
||||
+#else
|
||||
+
|
||||
// This needs more study, considering:
|
||||
// 1. the static linking option (maybe disable this in that case)
|
||||
// 2. the -z and -Z option issue
|
||||
@@ -1345,6 +1348,7 @@
|
||||
}
|
||||
return len;
|
||||
}
|
||||
+
|
||||
#endif
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
diff -Naur procps-ng-3.3.8.orig/pidof.c procps-ng-3.3.8/pidof.c
|
||||
--- procps-ng-3.3.8.orig/pidof.c 2013-11-04 16:10:02.000000000 +0100
|
||||
+++ procps-ng-3.3.8/pidof.c 2013-11-04 16:14:27.217193613 +0100
|
||||
@@ -133,7 +133,7 @@
|
||||
{
|
||||
PROCTAB *ptp;
|
||||
proc_t task;
|
||||
- int match, root_check_ok;
|
||||
+ int match;
|
||||
static int size = 0;
|
||||
char *cmd_arg0, *cmd_arg0base;
|
||||
char *cmd_arg1, *cmd_arg1base;
|
||||
@@ -351,9 +351,9 @@
|
||||
for (i = proc_count - 1; i >= 0; i--) { /* and display their PIDs */
|
||||
if (first_pid) {
|
||||
first_pid = 0;
|
||||
- printf ("%ld", procs[i].pid);
|
||||
+ printf ("%ld", (long) procs[i].pid);
|
||||
} else {
|
||||
- printf (" %ld", procs[i].pid);
|
||||
+ printf (" %ld", (long) procs[i].pid);
|
||||
}
|
||||
if (opt_single_shot) break;
|
||||
}
|
@ -1,552 +0,0 @@
|
||||
diff --git a/Makefile.am b/Makefile.am
|
||||
index 3d66d60..7075e67 100644
|
||||
--- a/Makefile.am
|
||||
+++ b/Makefile.am
|
||||
@@ -52,6 +52,14 @@ EXTRA_DIST = \
|
||||
Documentation/TODO \
|
||||
sysctl.conf
|
||||
|
||||
+if BUILD_PIDOF
|
||||
+usrbin_exec_PROGRAMS += pidof
|
||||
+dist_man_MANS += pidof.1
|
||||
+pidof_SOURCES = pidof.c $(top_srcdir)/lib/fileutils.c
|
||||
+else
|
||||
+ EXTRA_DIST += pidof.1
|
||||
+endif
|
||||
+
|
||||
if BUILD_KILL
|
||||
bin_PROGRAMS = kill
|
||||
dist_man_MANS += kill.1
|
||||
diff --git a/pidof.1 b/pidof.1
|
||||
new file mode 100644
|
||||
index 0000000..f2544c8
|
||||
--- /dev/null
|
||||
+++ b/pidof.1
|
||||
@@ -0,0 +1,60 @@
|
||||
+'\" -*- coding: UTF-8 -*-
|
||||
+.\" Copyright (C) 1998 Miquel van Smoorenburg.
|
||||
+.\"
|
||||
+.\" This program is free software; you can redistribute it and/or modify
|
||||
+.\" it under the terms of the GNU General Public License as published by
|
||||
+.\" the Free Software Foundation; either version 2 of the License, or
|
||||
+.\" (at your option) any later version.
|
||||
+.\"
|
||||
+.\" This program is distributed in the hope that it will be useful,
|
||||
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+.\" GNU General Public License for more details.
|
||||
+.\"
|
||||
+.\" You should have received a copy of the GNU General Public License
|
||||
+.\" along with this program; if not, write to the Free Software
|
||||
+.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
+.\"
|
||||
+.TH PIDOF 1 "24 Jul 2013" "" "User Commands"
|
||||
+.SH NAME
|
||||
+pidof -- find the process ID of a running program.
|
||||
+.SH SYNOPSIS
|
||||
+.B pidof
|
||||
+.RB [ \-s ]
|
||||
+.RB [ \-c ]
|
||||
+.RB [ \-x ]
|
||||
+.RB [ \-o
|
||||
+.IR omitpid[,omitpid..] ]
|
||||
+.RB [ \-o
|
||||
+.IR omitpid[,omitpid..].. ]
|
||||
+.B program
|
||||
+.RB [ program.. ]
|
||||
+.SH DESCRIPTION
|
||||
+.B Pidof
|
||||
+finds the process id's (pids) of the named programs. It prints those
|
||||
+id's on the standard output.
|
||||
+.SH OPTIONS
|
||||
+.IP \-s
|
||||
+Single shot - this instructs the program to only return one \fIpid\fP.
|
||||
+.IP \-c
|
||||
+Only return process ids that are running with the same root directory.
|
||||
+This option is ignored for non-root users, as they will be unable to check
|
||||
+the current root directory of processes they do not own.
|
||||
+.IP \-x
|
||||
+Scripts too - this causes the program to also return process id's of
|
||||
+shells running the named scripts.
|
||||
+.IP "-o \fIomitpid\fP"
|
||||
+Tells \fIpidof\fP to omit processes with that process id.
|
||||
+.SH "EXIT STATUS"
|
||||
+.TP
|
||||
+.B 0
|
||||
+At least one program was found with the requested name.
|
||||
+.TP
|
||||
+.B 1
|
||||
+No program was found with the requested name.
|
||||
+
|
||||
+.SH SEE ALSO
|
||||
+.BR pgrep (1),
|
||||
+.BR pkill (1)
|
||||
+.SH AUTHOR
|
||||
+Jaromir Capik <jcapik@redhat.com>
|
||||
diff --git a/pidof.c b/pidof.c
|
||||
new file mode 100644
|
||||
index 0000000..6cce24c
|
||||
--- /dev/null
|
||||
+++ b/pidof.c
|
||||
@@ -0,0 +1,371 @@
|
||||
+/*
|
||||
+ * pidof.c - Utility for listing pids of running processes
|
||||
+ *
|
||||
+ * Copyright (C) 2013 Jaromir Capik <jcapik@redhat.com>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU General Public License
|
||||
+ * as published by the Free Software Foundation; either version 2
|
||||
+ * of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License
|
||||
+ * along with this program; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
+ */
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include <getopt.h>
|
||||
+
|
||||
+#include "c.h"
|
||||
+#include "fileutils.h"
|
||||
+#include "nls.h"
|
||||
+#include "xalloc.h"
|
||||
+#include "proc/readproc.h"
|
||||
+#include "proc/sig.h"
|
||||
+#include "proc/devname.h"
|
||||
+#include "proc/sysinfo.h"
|
||||
+#include "proc/version.h" /* procps_version */
|
||||
+
|
||||
+
|
||||
+#define grow_size(x) (x = x * 5 / 4 + 1024)
|
||||
+#define safe_free(x) if (x) { free(x); x=NULL; }
|
||||
+
|
||||
+
|
||||
+struct el {
|
||||
+ pid_t pid;
|
||||
+};
|
||||
+
|
||||
+struct el *procs = NULL;
|
||||
+static int proc_count = 0;
|
||||
+
|
||||
+struct el *omitted_procs = NULL;
|
||||
+static int omit_count = 0;
|
||||
+
|
||||
+static char *program = NULL;
|
||||
+
|
||||
+/* switch flags */
|
||||
+static int opt_single_shot = 0; /* -s */
|
||||
+static int opt_scripts_too = 0; /* -x */
|
||||
+static int opt_rootdir_check = 0; /* -c */
|
||||
+
|
||||
+static char *pidof_root = NULL;
|
||||
+
|
||||
+static int __attribute__ ((__noreturn__)) usage(int opt)
|
||||
+{
|
||||
+ int err = (opt == '?');
|
||||
+ FILE *fp = err ? stderr : stdout;
|
||||
+
|
||||
+ fputs(USAGE_HEADER, fp);
|
||||
+ fprintf(fp, _(" %s [options] [program [...]]\n"), program_invocation_short_name);
|
||||
+ fputs(USAGE_OPTIONS, fp);
|
||||
+ fputs(_(" -s, --single-shot return one PID only\n"
|
||||
+ " -c, --check-root omit processes with different root\n"
|
||||
+ " -x scripts too\n"
|
||||
+ " -o, --omit-pid <PID,...> omit processes with PID\n"), fp);
|
||||
+ fputs(USAGE_SEPARATOR, fp);
|
||||
+ fputs(USAGE_HELP, fp);
|
||||
+ fputs(USAGE_VERSION, fp);
|
||||
+ fprintf(fp, USAGE_MAN_TAIL("pidof(1)"));
|
||||
+
|
||||
+ exit(fp == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int is_omitted (pid_t pid)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < omit_count; i++) {
|
||||
+ if (pid == omitted_procs[i].pid) return 1;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static char *get_basename (char *filename)
|
||||
+{
|
||||
+ char *pos;
|
||||
+ char *result;
|
||||
+
|
||||
+ pos = result = filename;
|
||||
+ while (*pos != '\0') {
|
||||
+ if (*(pos++) == '/') result = pos;
|
||||
+ }
|
||||
+
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static char *pid_link (pid_t pid, const char *base_name)
|
||||
+{
|
||||
+ char link [PROCPATHLEN];
|
||||
+ char *result;
|
||||
+ int path_alloc_size;
|
||||
+ int len;
|
||||
+
|
||||
+ snprintf(link, sizeof(link), "/proc/%d/%s", pid, base_name);
|
||||
+
|
||||
+ len = path_alloc_size = 0;
|
||||
+ result = NULL;
|
||||
+ do {
|
||||
+ if (len == path_alloc_size) {
|
||||
+ grow_size (path_alloc_size);
|
||||
+ result = (char *) xrealloc (result, path_alloc_size);
|
||||
+ }
|
||||
+
|
||||
+ if ((len = readlink(link, result, path_alloc_size - 1)) < 0) {
|
||||
+ len = 0;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ } while (len == path_alloc_size);
|
||||
+
|
||||
+ result[len] = '\0';
|
||||
+
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void select_procs (void)
|
||||
+{
|
||||
+ PROCTAB *ptp;
|
||||
+ proc_t task;
|
||||
+ int match, root_check_ok;
|
||||
+ static int size = 0;
|
||||
+ char *cmd_arg0, *cmd_arg0base;
|
||||
+ char *cmd_arg1, *cmd_arg1base;
|
||||
+ char *pos;
|
||||
+ char *program_base;
|
||||
+ char *root_link;
|
||||
+ char *exe_link;
|
||||
+ char *exe_link_base;
|
||||
+
|
||||
+ /* get the input base name */
|
||||
+ program_base = get_basename(program);
|
||||
+
|
||||
+ ptp = openproc (PROC_FILLCOM | PROC_FILLSTAT);
|
||||
+
|
||||
+ exe_link = root_link = NULL;
|
||||
+ memset(&task, 0, sizeof (task));
|
||||
+ while(readproc(ptp, &task)) {
|
||||
+
|
||||
+ if (opt_rootdir_check) {
|
||||
+ /* get the /proc/<pid>/root symlink value */
|
||||
+ root_link = pid_link(task.XXXID, "root");
|
||||
+ match = !strcmp(pidof_root, root_link);
|
||||
+ safe_free(root_link);
|
||||
+
|
||||
+ if (!match) { /* root check failed */
|
||||
+ memset (&task, 0, sizeof (task));
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!is_omitted(task.XXXID) && task.cmdline) {
|
||||
+
|
||||
+ cmd_arg0 = *task.cmdline;
|
||||
+
|
||||
+ /* processes starting with '-' are login shells */
|
||||
+ if (*cmd_arg0 == '-') {
|
||||
+ cmd_arg0++;
|
||||
+ }
|
||||
+
|
||||
+ /* get the argv0 base name */
|
||||
+ cmd_arg0base = get_basename(cmd_arg0);
|
||||
+
|
||||
+ /* get the /proc/<pid>/exe symlink value */
|
||||
+ exe_link = pid_link(task.XXXID, "exe");
|
||||
+
|
||||
+ /* get the exe_link base name */
|
||||
+ exe_link_base = get_basename(exe_link);
|
||||
+
|
||||
+ match = 0;
|
||||
+
|
||||
+ if (!strcmp(program, cmd_arg0base) ||
|
||||
+ !strcmp(program_base, cmd_arg0) ||
|
||||
+ !strcmp(program, cmd_arg0) ||
|
||||
+
|
||||
+ !strcmp(program, exe_link_base) ||
|
||||
+ !strcmp(program, exe_link))
|
||||
+ {
|
||||
+ match = 1;
|
||||
+
|
||||
+ } else if (opt_scripts_too && *(task.cmdline+1)) {
|
||||
+
|
||||
+ pos = cmd_arg1base = cmd_arg1 = *(task.cmdline+1);
|
||||
+
|
||||
+ /* get the arg1 base name */
|
||||
+ while (*pos != '\0') {
|
||||
+ if (*(pos++) == '/') cmd_arg1base = pos;
|
||||
+ }
|
||||
+
|
||||
+ /* if script, then task.cmd = argv1, otherwise task.cmd = argv0 */
|
||||
+ if (task.cmd &&
|
||||
+ !strncmp(task.cmd, cmd_arg1base, strlen(task.cmd)) &&
|
||||
+ (!strcmp(program, cmd_arg1base) ||
|
||||
+ !strcmp(program_base, cmd_arg1) ||
|
||||
+ !strcmp(program, cmd_arg1)))
|
||||
+ {
|
||||
+ match = 1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ safe_free(exe_link);
|
||||
+
|
||||
+ if (match) {
|
||||
+ if (proc_count == size) {
|
||||
+ grow_size(size);
|
||||
+ procs = xrealloc(procs, size * (sizeof *procs));
|
||||
+ }
|
||||
+ if (procs) {
|
||||
+ procs[proc_count++].pid = task.XXXID;
|
||||
+ } else {
|
||||
+ xerrx(EXIT_FAILURE, _("internal error"));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ memset (&task, 0, sizeof (task));
|
||||
+ }
|
||||
+
|
||||
+ closeproc (ptp);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void add_to_omit_list (char *input_arg)
|
||||
+{
|
||||
+ static int omit_size = 0;
|
||||
+
|
||||
+ char *omit_str;
|
||||
+ char *endptr;
|
||||
+
|
||||
+ pid_t omit_pid;
|
||||
+
|
||||
+ omit_str = NULL;
|
||||
+ omit_str = strtok(input_arg, ",");
|
||||
+ while (omit_str) {
|
||||
+
|
||||
+ omit_pid = strtoul(omit_str, &endptr, 10);
|
||||
+
|
||||
+ if (*endptr == '\0') {
|
||||
+ if (omit_count == omit_size) {
|
||||
+ grow_size(omit_size);
|
||||
+ omitted_procs = xrealloc(omitted_procs, omit_size * sizeof(*omitted_procs));
|
||||
+ }
|
||||
+ if (omitted_procs) {
|
||||
+ omitted_procs[omit_count++].pid = omit_pid;
|
||||
+ } else {
|
||||
+ xerrx(EXIT_FAILURE, _("internal error"));
|
||||
+ }
|
||||
+ } else {
|
||||
+ xwarnx(_("illegal omit pid value (%s)!\n"), omit_str);
|
||||
+ }
|
||||
+
|
||||
+ omit_str = strtok(NULL, ",");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+
|
||||
+
|
||||
+int main (int argc, char **argv)
|
||||
+{
|
||||
+ int opt;
|
||||
+ signed int i;
|
||||
+ int found = 0;
|
||||
+ int first_pid = 1;
|
||||
+
|
||||
+ const char *opts = "scnxmo:?Vh";
|
||||
+
|
||||
+ static const struct option longopts[] = {
|
||||
+ {"single-shot", no_argument, NULL, 's'},
|
||||
+ {"omit-pid", required_argument, NULL, 'o'},
|
||||
+ {"help", no_argument, NULL, 'h'},
|
||||
+ {"version", no_argument, NULL, 'V'},
|
||||
+ {NULL, 0, NULL, 0}
|
||||
+ };
|
||||
+
|
||||
+#ifdef HAVE_PROGRAM_INVOCATION_NAME
|
||||
+ program_invocation_name = program_invocation_short_name;
|
||||
+#endif
|
||||
+ setlocale (LC_ALL, "");
|
||||
+ bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
+ textdomain (PACKAGE);
|
||||
+ atexit (close_stdout);
|
||||
+
|
||||
+ /* process command-line options */
|
||||
+ while ((opt = getopt_long (argc, argv, opts, longopts, NULL)) != -1) {
|
||||
+ switch (opt) {
|
||||
+ case 's':
|
||||
+ opt_single_shot = 1;
|
||||
+ break;
|
||||
+ case 'o':
|
||||
+ add_to_omit_list (optarg);
|
||||
+ break;
|
||||
+ case 'x':
|
||||
+ opt_scripts_too = 1;
|
||||
+ break;
|
||||
+ case 'c':
|
||||
+ if (geteuid() == 0) {
|
||||
+ opt_rootdir_check = 1;
|
||||
+ pidof_root = pid_link(getpid(), "root");
|
||||
+ }
|
||||
+ break;
|
||||
+ case 'V':
|
||||
+ printf (PROCPS_NG_VERSION);
|
||||
+ exit (EXIT_SUCCESS);
|
||||
+ case 'h':
|
||||
+ case '?':
|
||||
+ usage (opt);
|
||||
+ break;
|
||||
+ /* compatibility-only switches */
|
||||
+ case 'n': /* avoiding stat(2) on NFS volumes doesn't make any sense anymore ... */
|
||||
+ /* ... as this reworked solution does not use stat(2) at all */
|
||||
+ case 'm': /* omitting relatives with argv[0] & argv[1] matching the argv[0] & argv[1] ...*/
|
||||
+ /* ... of explicitly omitted PIDs is too 'expensive' and as we don't know */
|
||||
+ /* ... wheter it is still needed, we won't re-implement it unless ... */
|
||||
+ /* ... somebody gives us a good reason to do so :) */
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* main loop */
|
||||
+ while (argc - optind) { /* for each program */
|
||||
+
|
||||
+ program = argv[optind++];
|
||||
+
|
||||
+ select_procs(); /* get the list of matching processes */
|
||||
+
|
||||
+ if (proc_count) {
|
||||
+
|
||||
+ found = 1;
|
||||
+ for (i = proc_count - 1; i >= 0; i--) { /* and display their PIDs */
|
||||
+ if (first_pid) {
|
||||
+ first_pid = 0;
|
||||
+ printf ("%ld", procs[i].pid);
|
||||
+ } else {
|
||||
+ printf (" %ld", procs[i].pid);
|
||||
+ }
|
||||
+ if (opt_single_shot) break;
|
||||
+ }
|
||||
+
|
||||
+ proc_count = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* final line feed */
|
||||
+ if (found) printf("\n");
|
||||
+
|
||||
+ /* some cleaning */
|
||||
+ safe_free(procs);
|
||||
+ safe_free(omitted_procs);
|
||||
+ safe_free(pidof_root);
|
||||
+
|
||||
+ return !found;
|
||||
+}
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
diff --git a/pidof.c b/pidof.c
|
||||
index 6cce24c..a39a4c0 100644
|
||||
--- a/pidof.c
|
||||
+++ b/pidof.c
|
||||
@@ -26,9 +26,6 @@
|
||||
#include "nls.h"
|
||||
#include "xalloc.h"
|
||||
#include "proc/readproc.h"
|
||||
-#include "proc/sig.h"
|
||||
-#include "proc/devname.h"
|
||||
-#include "proc/sysinfo.h"
|
||||
#include "proc/version.h" /* procps_version */
|
||||
|
||||
|
||||
@@ -284,6 +281,7 @@ int main (int argc, char **argv)
|
||||
const char *opts = "scnxmo:?Vh";
|
||||
|
||||
static const struct option longopts[] = {
|
||||
+ {"check-root", no_argument, NULL, 'c'},
|
||||
{"single-shot", no_argument, NULL, 's'},
|
||||
{"omit-pid", required_argument, NULL, 'o'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
diff --git a/pidof.1 b/pidof.1
|
||||
index f2544c8..f49cd23 100644
|
||||
--- a/pidof.1
|
||||
+++ b/pidof.1
|
||||
@@ -44,7 +44,9 @@ the current root directory of processes they do not own.
|
||||
Scripts too - this causes the program to also return process id's of
|
||||
shells running the named scripts.
|
||||
.IP "-o \fIomitpid\fP"
|
||||
-Tells \fIpidof\fP to omit processes with that process id.
|
||||
+Tells \fIpidof\fP to omit processes with that process id. The special
|
||||
+pid \fB%PPID\fP can be used to name the parent process of the \fIpidof\fP
|
||||
+program, in other words the calling shell or shell script.
|
||||
.SH "EXIT STATUS"
|
||||
.TP
|
||||
.B 0
|
||||
diff --git a/pidof.c b/pidof.c
|
||||
index a39a4c0..72344e7 100644
|
||||
--- a/pidof.c
|
||||
+++ b/pidof.c
|
||||
@@ -246,10 +246,15 @@ static void add_to_omit_list (char *input_arg)
|
||||
pid_t omit_pid;
|
||||
|
||||
omit_str = NULL;
|
||||
- omit_str = strtok(input_arg, ",");
|
||||
+ omit_str = strtok(input_arg, ",;:");
|
||||
while (omit_str) {
|
||||
|
||||
- omit_pid = strtoul(omit_str, &endptr, 10);
|
||||
+ if (!strcmp(omit_str,"%PPID")) { /* keeping this %PPID garbage for backward compatibility only */
|
||||
+ omit_pid = getppid(); /* ... as it can be replaced with $$ in common shells */
|
||||
+ endptr = omit_str + sizeof("%PPID") - 1;
|
||||
+ } else {
|
||||
+ omit_pid = strtoul(omit_str, &endptr, 10);
|
||||
+ }
|
||||
|
||||
if (*endptr == '\0') {
|
||||
if (omit_count == omit_size) {
|
||||
@@ -265,7 +270,7 @@ static void add_to_omit_list (char *input_arg)
|
||||
xwarnx(_("illegal omit pid value (%s)!\n"), omit_str);
|
||||
}
|
||||
|
||||
- omit_str = strtok(NULL, ",");
|
||||
+ omit_str = strtok(NULL, ",;:");
|
||||
}
|
||||
}
|
||||
|
||||
diff -Naur procps-ng-3.3.8.orig/configure.ac procps-ng-3.3.8/configure.ac
|
||||
--- procps-ng-3.3.8.orig/configure.ac 2013-10-16 19:45:54.000000000 +0200
|
||||
+++ procps-ng-3.3.8/configure.ac 2013-10-16 19:46:56.057000000 +0200
|
||||
@@ -168,6 +168,12 @@
|
||||
fi
|
||||
|
||||
# AC_ARG_ENABLEs
|
||||
+AC_ARG_ENABLE([pidof],
|
||||
+ AS_HELP_STRING([--disable-pidof], [do not build pidof]),
|
||||
+ [], [enable_pidof=yes]
|
||||
+)
|
||||
+AM_CONDITIONAL(BUILD_PIDOF, test "x$enable_pidof" = xyes)
|
||||
+
|
||||
AC_ARG_ENABLE([kill],
|
||||
AS_HELP_STRING([--disable-kill], [do not build kill]),
|
||||
[], enable_kill=yes
|
@ -3,8 +3,8 @@
|
||||
|
||||
Summary: System and process monitoring utilities
|
||||
Name: procps-ng
|
||||
Version: 3.3.8
|
||||
Release: 17%{?dist}
|
||||
Version: 3.3.9
|
||||
Release: 1%{?dist}
|
||||
License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+
|
||||
Group: Applications/System
|
||||
URL: https://sourceforge.net/projects/procps-ng/
|
||||
@ -12,22 +12,6 @@ URL: https://sourceforge.net/projects/procps-ng/
|
||||
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz
|
||||
Source1: pidof
|
||||
|
||||
Patch0: 0001-top-add-the-major-version-to-dlopen-of-libnuma-sonam.patch
|
||||
Patch1: 0002-library-for-atexit-support-fix-fileutils-for-EPIPE.patch
|
||||
Patch2: 0001-top-enable-screen-contents-preservation-at-end-of-jo.patch
|
||||
Patch3: 0001-top-refine-some-miscellaneous-signals-interrupt-stuf.patch
|
||||
Patch4: 0002-top-cursor-repositioning-includes-line-oriented-inpu.patch
|
||||
Patch5: procps-ng-3.3.8-RH-man-page-check.patch
|
||||
Patch6: procps-ng-3.3.8-libselinux.patch
|
||||
Patch7: procps-ng-3.3.8-free-shmem.patch
|
||||
Patch8: 0002-top-restore-the-lost-final-newline-when-in-Batch-mod.patch
|
||||
Patch9: procps-add_support_for_linux_namespaces.patch
|
||||
Patch10: pgrep-introduce_support_for_namespaces.patch
|
||||
Patch11: skill-support_namespaces.patch
|
||||
Patch12: procps-fix_the_fatal_make_dist_error_for_nsutils.patch
|
||||
Patch13: procps-ng-3.3.8-pidof.patch
|
||||
Patch14: procps-ng-3.3.8-pidof-warnings.patch
|
||||
|
||||
Requires(post): /sbin/ldconfig
|
||||
Requires(postun): /sbin/ldconfig
|
||||
|
||||
@ -90,22 +74,6 @@ System and process monitoring utilities development headers
|
||||
%prep
|
||||
%setup -q -n %{name}-%{version}
|
||||
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
%patch6 -p1
|
||||
%patch7 -p1
|
||||
%patch8 -p1
|
||||
%patch9 -p1
|
||||
%patch10 -p1
|
||||
%patch11 -p1
|
||||
%patch12 -p1
|
||||
%patch13 -p1
|
||||
%patch14 -p1
|
||||
|
||||
|
||||
%build
|
||||
# The following stuff is needed for git archives only
|
||||
@ -174,6 +142,9 @@ install -pm755 %{SOURCE1} %{buildroot}%{_sbindir}
|
||||
%{_includedir}/proc
|
||||
|
||||
%changelog
|
||||
* Tue Dec 03 2013 Jaromir Capik <jcapik@redhat.com> - 3.3.9-1
|
||||
- Update to 3.3.9
|
||||
|
||||
* Mon Nov 04 2013 Jaromir Capik <jcapik@redhat.com> - 3.3.8-17
|
||||
- Fixing pidof compilation warnings
|
||||
- RPM workaround - changing sysvinit-tools Conflicts/Obsoletes (#1026504)
|
||||
|
@ -1,228 +0,0 @@
|
||||
commit 91d225f3b8fcfa514f1ef20239af7b0ada64c01c
|
||||
Author: Aristeu Rozanski <arozansk@redhat.com>
|
||||
Date: Tue Apr 16 12:07:10 2013 -0400
|
||||
|
||||
skill: support namespaces
|
||||
|
||||
In the same fashion of pgrep, introduce two new options:
|
||||
--ns <pid>
|
||||
- nslist <ns,...>
|
||||
which allows processes to be filtered by namespace.
|
||||
|
||||
Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
|
||||
|
||||
diff --git a/Makefile.am b/Makefile.am
|
||||
index 05128a4..3d66d60 100644
|
||||
--- a/Makefile.am
|
||||
+++ b/Makefile.am
|
||||
@@ -55,7 +55,7 @@ EXTRA_DIST = \
|
||||
if BUILD_KILL
|
||||
bin_PROGRAMS = kill
|
||||
dist_man_MANS += kill.1
|
||||
-kill_SOURCES = skill.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c
|
||||
+kill_SOURCES = skill.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c $(top_srcdir)/lib/nsutils.c
|
||||
else
|
||||
EXTRA_DIST += kill.1
|
||||
endif
|
||||
@@ -77,8 +77,8 @@ if BUILD_SKILL
|
||||
usrbin_exec_PROGRAMS += \
|
||||
skill \
|
||||
snice
|
||||
-skill_SOURCES = skill.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c
|
||||
-snice_SOURCES = skill.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c
|
||||
+skill_SOURCES = skill.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c $(top_srcdir)/lib/nsutils.c
|
||||
+snice_SOURCES = skill.c $(top_srcdir)/lib/strutils.c $(top_srcdir)/lib/fileutils.c $(top_srcdir)/lib/nsutils.c
|
||||
dist_man_MANS += \
|
||||
skill.1 \
|
||||
snice.1
|
||||
diff --git a/skill.1 b/skill.1
|
||||
index 9748a1d..8ef7683 100644
|
||||
--- a/skill.1
|
||||
+++ b/skill.1
|
||||
@@ -77,6 +77,13 @@ The next expression is a process ID number.
|
||||
.TP
|
||||
\fB\-c\fR, \fB\-\-command\fR \fIcommand\fR
|
||||
The next expression is a command name.
|
||||
+.TP
|
||||
+\fB\-\-ns \fIpid\fR
|
||||
+Match the processes that belong to the same namespace as pid.
|
||||
+.TP
|
||||
+\fB\-\-nslist \fIns,...\fR
|
||||
+list which namespaces will be considered for the --ns option.
|
||||
+Available namespaces: ipc, mnt, net, pid, user, uts.
|
||||
.PD
|
||||
.SH SIGNALS
|
||||
The behavior of signals is explained in
|
||||
diff --git a/skill.c b/skill.c
|
||||
index 03df229..d3fc978 100644
|
||||
--- a/skill.c
|
||||
+++ b/skill.c
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "c.h"
|
||||
#include "fileutils.h"
|
||||
+#include "nsutils.h"
|
||||
#include "strutils.h"
|
||||
#include "nls.h"
|
||||
#include "xalloc.h"
|
||||
@@ -43,6 +44,7 @@
|
||||
#include "proc/sig.h"
|
||||
#include "proc/devname.h"
|
||||
#include "proc/procps.h" /* char *user_from_uid(uid_t uid) */
|
||||
+#include "proc/readproc.h"
|
||||
#include "proc/version.h" /* procps_version */
|
||||
#include "rpmatch.h"
|
||||
|
||||
@@ -56,11 +58,14 @@ struct run_time_conf_t {
|
||||
int noaction;
|
||||
int debugging;
|
||||
};
|
||||
-static int tty_count, uid_count, cmd_count, pid_count;
|
||||
+static int tty_count, uid_count, cmd_count, pid_count, namespace_count;
|
||||
static int *ttys;
|
||||
static uid_t *uids;
|
||||
static const char **cmds;
|
||||
static int *pids;
|
||||
+static char **namespaces;
|
||||
+static int ns_pid;
|
||||
+static proc_t ns_task;
|
||||
|
||||
#define ENLIST(thing,addme) do{ \
|
||||
if(!thing##s) thing##s = xmalloc(sizeof(*thing##s)*saved_argc); \
|
||||
@@ -85,6 +90,39 @@ static void display_kill_version(void)
|
||||
fprintf(stdout, PROCPS_NG_VERSION);
|
||||
}
|
||||
|
||||
+static int ns_flags = 0x3f;
|
||||
+static int parse_namespaces(char *optarg)
|
||||
+{
|
||||
+ char *ptr = optarg, *tmp;
|
||||
+ int len, id;
|
||||
+
|
||||
+ ns_flags = 0;
|
||||
+ while (1) {
|
||||
+ if (strchr(ptr, ',') == NULL) {
|
||||
+ len = -1;
|
||||
+ tmp = strdup(ptr);
|
||||
+ } else {
|
||||
+ len = strchr(ptr, ',') - ptr;
|
||||
+ tmp = strndup(ptr, len);
|
||||
+ }
|
||||
+
|
||||
+ id = get_ns_id(tmp);
|
||||
+ if (id == -1) {
|
||||
+ fprintf(stderr, "%s is not a valid namespace\n", tmp);
|
||||
+ free(tmp);
|
||||
+ return 1;
|
||||
+ }
|
||||
+ ns_flags |= (1 << id);
|
||||
+ ENLIST(namespace, tmp);
|
||||
+
|
||||
+ if (len == -1)
|
||||
+ break;
|
||||
+
|
||||
+ ptr+= len + 1;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
/* kill or nice a process */
|
||||
static void hurt_proc(int tty, int uid, int pid, const char *restrict const cmd,
|
||||
struct run_time_conf_t *run_time)
|
||||
@@ -131,6 +169,7 @@ static void check_proc(int pid, struct run_time_conf_t *run_time)
|
||||
{
|
||||
char buf[128];
|
||||
struct stat statbuf;
|
||||
+ proc_t task;
|
||||
char *tmp;
|
||||
int tty;
|
||||
int fd;
|
||||
@@ -183,6 +222,16 @@ static void check_proc(int pid, struct run_time_conf_t *run_time)
|
||||
if (i == -1)
|
||||
goto closure;
|
||||
}
|
||||
+ if (ns_pid) {
|
||||
+ if (ns_read(pid, &task))
|
||||
+ goto closure;
|
||||
+ for (i = 0; i < NUM_NS; i++) {
|
||||
+ if (ns_flags & (1 << i)) {
|
||||
+ if (task.ns[i] != ns_task.ns[i])
|
||||
+ goto closure;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
/* This is where we kill/nice something. */
|
||||
/* for debugging purposes?
|
||||
fprintf(stderr, "PID %d, UID %d, TTY %d,%d, COMM %s\n",
|
||||
@@ -317,6 +366,15 @@ static void __attribute__ ((__noreturn__)) skillsnice_usage(FILE * out)
|
||||
" -t, --tty <tty> expression is a terminal\n"
|
||||
" -u, --user <username> expression is a username\n"), out);
|
||||
fputs(USAGE_SEPARATOR, out);
|
||||
+ fputs(_("Alternatively, expression can be:\n"
|
||||
+ " --ns <pid> match the processes that belong to the same\n"
|
||||
+ " namespace as <pid>\n"
|
||||
+ " --nslist <ns,...> list which namespaces will be considered for\n"
|
||||
+ " the --ns option.\n"
|
||||
+ " Available namespaces: ipc, mnt, net, pid, user, uts\n"), out);
|
||||
+
|
||||
+ fputs(USAGE_SEPARATOR, out);
|
||||
+ fputs(USAGE_SEPARATOR, out);
|
||||
fputs(USAGE_HELP, out);
|
||||
fputs(USAGE_VERSION, out);
|
||||
if (program == PROG_SKILL) {
|
||||
@@ -488,6 +546,11 @@ static void skillsnice_parse(int argc,
|
||||
int prino = DEFAULT_NICE;
|
||||
int ch, i;
|
||||
|
||||
+ enum {
|
||||
+ NS_OPTION = CHAR_MAX + 1,
|
||||
+ NSLIST_OPTION,
|
||||
+ };
|
||||
+
|
||||
static const struct option longopts[] = {
|
||||
{"command", required_argument, NULL, 'c'},
|
||||
{"debug", no_argument, NULL, 'd'},
|
||||
@@ -499,6 +562,8 @@ static void skillsnice_parse(int argc,
|
||||
{"table", no_argument, NULL, 'L'},
|
||||
{"tty", required_argument, NULL, 't'},
|
||||
{"user", required_argument, NULL, 'u'},
|
||||
+ {"ns", required_argument, NULL, NS_OPTION},
|
||||
+ {"nslist", required_argument, NULL, NSLIST_OPTION},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"warnings", no_argument, NULL, 'w'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
@@ -572,6 +637,25 @@ static void skillsnice_parse(int argc,
|
||||
}
|
||||
}
|
||||
break;
|
||||
+ case NS_OPTION:
|
||||
+ ns_pid = atoi(optarg);
|
||||
+ if (ns_pid == 0) {
|
||||
+ xwarnx(_("invalid pid number %i"), optarg);
|
||||
+ kill_usage(stderr);
|
||||
+ }
|
||||
+ if (ns_read(ns_pid, &ns_task)) {
|
||||
+ xwarnx(_("error reading reference namespace "
|
||||
+ "information"));
|
||||
+ kill_usage(stderr);
|
||||
+ }
|
||||
+
|
||||
+ break;
|
||||
+ case NSLIST_OPTION:
|
||||
+ if (parse_namespaces(optarg)) {
|
||||
+ xwarnx(_("invalid namespace list"));
|
||||
+ kill_usage(stderr);
|
||||
+ }
|
||||
+ break;
|
||||
case 'v':
|
||||
run_time->verbose = 1;
|
||||
break;
|
||||
@@ -605,7 +689,7 @@ static void skillsnice_parse(int argc,
|
||||
}
|
||||
|
||||
/* No more arguments to process. Must sanity check. */
|
||||
- if (!tty_count && !uid_count && !cmd_count && !pid_count)
|
||||
+ if (!tty_count && !uid_count && !cmd_count && !pid_count && !ns_pid)
|
||||
xerrx(EXIT_FAILURE, _("no process selection criteria"));
|
||||
if ((run_time->fast | run_time->interactive | run_time->
|
||||
verbose | run_time->warnings | run_time->noaction) & ~1)
|
Loading…
Reference in New Issue
Block a user