1 Star 0 Fork 25

yueyaoqiang/procps-ng

forked from src-openEuler/procps-ng 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
openeuler-add-M-and-N-options-for-top.patch 2.98 KB
一键复制 编辑 原始数据 按行查看 历史
Venland 提交于 2023-11-01 10:15 +08:00 . update to version v4.0.4
From 6e59f5e746c15df4d4b53f2df85b64aa1f10d0c3 Mon Sep 17 00:00:00 2001
From: xuchunmei <xuchunmei@huawei.com>
Date: Fri, 11 Jan 2019 01:29:55 -0500
Subject: [PATCH] procps-ng: add -M and -N options for top
Signed-off-by: xuchunmei <xuchunmei@huawei.com>
Signed-off-by: zhoujie <zhoujie133@huawei.com>
Signed-off-by: Qiang Wei <qiang.wei@suse.com>
Signed-off-by: liweigang <weigangli99@gmail.com>
---
src/top/top.c | 15 ++++++++++++++-
src/top/top_nls.c | 2 ++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/top/top.c b/src/top/top.c
index 969c553..466341f 100644
--- a/src/top/top.c
+++ b/src/top/top.c
@@ -4243,7 +4243,7 @@ default_or_error:
* overridden -- we'll force some on and negate others in our
* best effort to honor the loser's (oops, user's) wishes... */
static void parse_args (int argc, char **argv) {
- static const char sopts[] = "bcd:E:e:Hhin:Oo:p:SsU:u:Vw::1";
+ static const char sopts[] = "bcd:E:e:Hhin:Oo:p:SsU:u:Vw::1MN:";
static const struct option lopts[] = {
{ "batch-mode", no_argument, NULL, 'b' },
{ "cmdline-toggle", no_argument, NULL, 'c' },
@@ -4264,6 +4264,8 @@ static void parse_args (int argc, char **argv) {
{ "version", no_argument, NULL, 'V' },
{ "width", optional_argument, NULL, 'w' },
{ "single-cpu-toggle", no_argument, NULL, '1' },
+ { "sort-by-mem", no_argument, NULL, 'M' },
+ { "display-task-num", required_argument, NULL, 'N' },
{ NULL, 0, NULL, 0 }
};
float tmp_delay = FLT_MAX;
@@ -4386,6 +4388,17 @@ static void parse_args (int argc, char **argv) {
error_exit(fmtmk(N_fmt(BAD_widtharg_fmt), cp));
Width_mode = (int)tmp;
continue;
+ case 'M':
+ {
+ Curwin->rc.sortindx = EU_MEM;
+ break;
+ }
+ case 'N':
+ {
+ if (sscanf(cp, "%d", &Curwin->rc.maxtasks) != 1 || Curwin->rc.maxtasks < 0)
+ error_exit(fmtmk("bad iterations arg '%s'", cp));
+ continue;
+ }
default:
/* we'll rely on getopt for any error message while
forcing an EXIT_FAILURE with an empty string ... */
diff --git a/src/top/top_nls.c b/src/top/top_nls.c
index d7ab8dc..0201d64 100644
--- a/src/top/top_nls.c
+++ b/src/top/top_nls.c
@@ -431,6 +431,8 @@ static void build_norm_nlstab (void) {
" -u, --filter-only-euser =USER show only processes owned by USER\n"
" -w, --width [=COLUMNS] change print width [,use COLUMNS]\n"
" -1, --single-cpu-toggle reverse last remembered '1' state\n"
+ " -M, --sort-by-mem show tasks by memory usage\n"
+ " -N, --show-task-num show the specified number of tasks\n"
"\n"
" -h, --help display this help text, then exit\n"
" -V, --version output version information & exit\n"
--
2.41.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yueyaoqiang/procps-ng.git
git@gitee.com:yueyaoqiang/procps-ng.git
yueyaoqiang
procps-ng
procps-ng
master

搜索帮助