1 /* SPDX-License-Identifier: LGPL-2.1+ */
14 #include "alloc-util.h"
15 #include "bus-error.h"
17 #include "cgroup-show.h"
18 #include "cgroup-util.h"
22 #include "main-func.h"
23 #include "parse-util.h"
24 #include "path-util.h"
25 #include "pretty-print.h"
26 #include "process-util.h"
27 #include "procfs-util.h"
28 #include "sort-util.h"
29 #include "stdio-util.h"
31 #include "terminal-util.h"
32 #include "unit-name.h"
35 typedef struct Group
{
45 unsigned cpu_iteration
;
52 unsigned io_iteration
;
53 uint64_t io_input
, io_output
;
55 uint64_t io_input_bps
, io_output_bps
;
58 static unsigned arg_depth
= 3;
59 static unsigned arg_iterations
= (unsigned) -1;
60 static bool arg_batch
= false;
61 static bool arg_raw
= false;
62 static usec_t arg_delay
= 1*USEC_PER_SEC
;
63 static char* arg_machine
= NULL
;
64 static char* arg_root
= NULL
;
65 static bool arg_recursive
= true;
66 static bool arg_recursive_unset
= false;
70 COUNT_USERSPACE_PROCESSES
,
72 } arg_count
= COUNT_PIDS
;
80 } arg_order
= ORDER_CPU
;
85 } arg_cpu_type
= CPU_PERCENT
;
87 static Group
*group_free(Group
*g
) {
95 static const char *maybe_format_bytes(char *buf
, size_t l
, bool is_valid
, uint64_t t
) {
99 snprintf(buf
, l
, "%" PRIu64
, t
);
102 return format_bytes(buf
, l
, t
);
105 static bool is_root_cgroup(const char *path
) {
107 /* Returns true if the specified path belongs to the root cgroup. The root cgroup is special on cgroup v2 as it
108 * carries only very few attributes in order not to export multiple truth about system state as most
109 * information is available elsewhere in /proc anyway. We need to be able to deal with that, and need to get
110 * our data from different sources in that case.
112 * There's one extra complication in all of this, though 😣: if the path to the cgroup indicates we are in the
113 * root cgroup this might actually not be the case, because cgroup namespacing might be in effect
114 * (CLONE_NEWCGROUP). Since there's no nice way to distinguish a real cgroup root from a fake namespaced one we
115 * do an explicit container check here, under the assumption that CLONE_NEWCGROUP is generally used when
116 * container managers are used too.
118 * Note that checking for a container environment is kinda ugly, since in theory people could use cgtop from
119 * inside a container where cgroup namespacing is turned off to watch the host system. However, that's mostly a
120 * theoretic usecase, and if people actually try all they'll lose is accounting for the top-level cgroup. Which
123 if (detect_container() > 0)
126 return empty_or_root(path
);
130 const char *controller
,
144 all_unified
= cg_all_unified();
148 g
= hashmap_get(a
, path
);
150 g
= hashmap_get(b
, path
);
156 g
->path
= strdup(path
);
162 r
= hashmap_put(a
, g
->path
, g
);
168 r
= hashmap_move_one(a
, b
, path
);
172 g
->cpu_valid
= g
->memory_valid
= g
->io_valid
= g
->n_tasks_valid
= false;
176 if (streq(controller
, SYSTEMD_CGROUP_CONTROLLER
) &&
177 IN_SET(arg_count
, COUNT_ALL_PROCESSES
, COUNT_USERSPACE_PROCESSES
)) {
178 _cleanup_fclose_
FILE *f
= NULL
;
181 r
= cg_enumerate_processes(controller
, path
, &f
);
188 while (cg_read_pid(f
, &pid
) > 0) {
190 if (arg_count
== COUNT_USERSPACE_PROCESSES
&& is_kernel_thread(pid
) > 0)
197 g
->n_tasks_valid
= true;
199 } else if (streq(controller
, "pids") && arg_count
== COUNT_PIDS
) {
201 if (is_root_cgroup(path
)) {
202 r
= procfs_tasks_get_current(&g
->n_tasks
);
206 _cleanup_free_
char *p
= NULL
, *v
= NULL
;
208 r
= cg_get_path(controller
, path
, "pids.current", &p
);
212 r
= read_one_line_file(p
, &v
);
218 r
= safe_atou64(v
, &g
->n_tasks
);
224 g
->n_tasks_valid
= true;
226 } else if (streq(controller
, "memory")) {
228 if (is_root_cgroup(path
)) {
229 r
= procfs_memory_get_used(&g
->memory
);
233 _cleanup_free_
char *p
= NULL
, *v
= NULL
;
236 r
= cg_get_path(controller
, path
, "memory.current", &p
);
238 r
= cg_get_path(controller
, path
, "memory.usage_in_bytes", &p
);
242 r
= read_one_line_file(p
, &v
);
248 r
= safe_atou64(v
, &g
->memory
);
254 g
->memory_valid
= true;
256 } else if ((streq(controller
, "io") && all_unified
) ||
257 (streq(controller
, "blkio") && !all_unified
)) {
258 _cleanup_fclose_
FILE *f
= NULL
;
259 _cleanup_free_
char *p
= NULL
;
260 uint64_t wr
= 0, rd
= 0;
263 r
= cg_get_path(controller
, path
, all_unified
? "io.stat" : "blkio.io_service_bytes", &p
);
275 _cleanup_free_
char *line
= NULL
;
279 r
= read_line(f
, LONG_LINE_MAX
, &line
);
285 /* Trim and skip the device */
287 l
+= strcspn(l
, WHITESPACE
);
288 l
+= strspn(l
, WHITESPACE
);
291 while (!isempty(l
)) {
292 if (sscanf(l
, "rbytes=%" SCNu64
, &k
))
294 else if (sscanf(l
, "wbytes=%" SCNu64
, &k
))
297 l
+= strcspn(l
, WHITESPACE
);
298 l
+= strspn(l
, WHITESPACE
);
301 if (first_word(l
, "Read")) {
304 } else if (first_word(l
, "Write")) {
310 l
+= strspn(l
, WHITESPACE
);
311 r
= safe_atou64(l
, &k
);
319 timestamp
= now_nsec(CLOCK_MONOTONIC
);
321 if (g
->io_iteration
== iteration
- 1) {
324 x
= (uint64_t) (timestamp
- g
->io_timestamp
);
328 if (rd
> g
->io_input
)
329 yr
= rd
- g
->io_input
;
333 if (wr
> g
->io_output
)
334 yw
= wr
- g
->io_output
;
338 if (yr
> 0 || yw
> 0) {
339 g
->io_input_bps
= (yr
* 1000000000ULL) / x
;
340 g
->io_output_bps
= (yw
* 1000000000ULL) / x
;
347 g
->io_timestamp
= timestamp
;
348 g
->io_iteration
= iteration
;
349 } else if (STR_IN_SET(controller
, "cpu", "cpuacct") || cpu_accounting_is_cheap()) {
350 _cleanup_free_
char *p
= NULL
, *v
= NULL
;
354 if (is_root_cgroup(path
)) {
355 r
= procfs_cpu_get_usage(&new_usage
);
358 } else if (all_unified
) {
359 _cleanup_free_
char *val
= NULL
;
361 if (!streq(controller
, "cpu"))
364 r
= cg_get_keyed_attribute("cpu", path
, "cpu.stat", STRV_MAKE("usage_usec"), &val
);
365 if (IN_SET(r
, -ENOENT
, -ENXIO
))
370 r
= safe_atou64(val
, &new_usage
);
374 new_usage
*= NSEC_PER_USEC
;
376 if (!streq(controller
, "cpuacct"))
379 r
= cg_get_path(controller
, path
, "cpuacct.usage", &p
);
383 r
= read_one_line_file(p
, &v
);
389 r
= safe_atou64(v
, &new_usage
);
394 timestamp
= now_nsec(CLOCK_MONOTONIC
);
396 if (g
->cpu_iteration
== iteration
- 1 &&
397 (nsec_t
) new_usage
> g
->cpu_usage
) {
401 x
= timestamp
- g
->cpu_timestamp
;
405 y
= (nsec_t
) new_usage
- g
->cpu_usage
;
406 g
->cpu_fraction
= (double) y
/ (double) x
;
410 g
->cpu_usage
= (nsec_t
) new_usage
;
411 g
->cpu_timestamp
= timestamp
;
412 g
->cpu_iteration
= iteration
;
422 static int refresh_one(
423 const char *controller
,
431 _cleanup_closedir_
DIR *d
= NULL
;
439 if (depth
> arg_depth
)
442 r
= process(controller
, path
, a
, b
, iteration
, &ours
);
446 r
= cg_enumerate_subgroups(controller
, path
, &d
);
453 _cleanup_free_
char *fn
= NULL
, *p
= NULL
;
456 r
= cg_read_subgroup(d
, &fn
);
462 p
= path_join(path
, fn
);
466 path_simplify(p
, false);
468 r
= refresh_one(controller
, p
, a
, b
, iteration
, depth
+ 1, &child
);
473 IN_SET(arg_count
, COUNT_ALL_PROCESSES
, COUNT_USERSPACE_PROCESSES
) &&
475 child
->n_tasks_valid
&&
476 streq(controller
, SYSTEMD_CGROUP_CONTROLLER
)) {
478 /* Recursively sum up processes */
480 if (ours
->n_tasks_valid
)
481 ours
->n_tasks
+= child
->n_tasks
;
483 ours
->n_tasks
= child
->n_tasks
;
484 ours
->n_tasks_valid
= true;
495 static int refresh(const char *root
, Hashmap
*a
, Hashmap
*b
, unsigned iteration
) {
499 FOREACH_STRING(c
, SYSTEMD_CGROUP_CONTROLLER
, "cpu", "cpuacct", "memory", "io", "blkio", "pids") {
500 r
= refresh_one(c
, root
, a
, b
, iteration
, 0, NULL
);
508 static int group_compare(Group
* const *a
, Group
* const *b
) {
509 const Group
*x
= *a
, *y
= *b
;
512 if (arg_order
!= ORDER_TASKS
|| arg_recursive
) {
513 /* Let's make sure that the parent is always before
514 * the child. Except when ordering by tasks and
515 * recursive summing is off, since that is actually
516 * not accumulative for all children. */
518 if (path_startswith(empty_to_root(y
->path
), empty_to_root(x
->path
)))
520 if (path_startswith(empty_to_root(x
->path
), empty_to_root(y
->path
)))
530 if (arg_cpu_type
== CPU_PERCENT
) {
531 if (x
->cpu_valid
&& y
->cpu_valid
) {
532 r
= CMP(y
->cpu_fraction
, x
->cpu_fraction
);
535 } else if (x
->cpu_valid
)
537 else if (y
->cpu_valid
)
540 r
= CMP(y
->cpu_usage
, x
->cpu_usage
);
548 if (x
->n_tasks_valid
&& y
->n_tasks_valid
) {
549 r
= CMP(y
->n_tasks
, x
->n_tasks
);
552 } else if (x
->n_tasks_valid
)
554 else if (y
->n_tasks_valid
)
560 if (x
->memory_valid
&& y
->memory_valid
) {
561 r
= CMP(y
->memory
, x
->memory
);
564 } else if (x
->memory_valid
)
566 else if (y
->memory_valid
)
572 if (x
->io_valid
&& y
->io_valid
) {
573 r
= CMP(y
->io_input_bps
+ y
->io_output_bps
, x
->io_input_bps
+ x
->io_output_bps
);
576 } else if (x
->io_valid
)
578 else if (y
->io_valid
)
582 return path_compare(x
->path
, y
->path
);
585 static void display(Hashmap
*a
) {
590 unsigned rows
, n
= 0, j
, maxtcpu
= 0, maxtpath
= 3; /* 3 for ellipsize() to work properly */
591 char buffer
[MAX3(21, FORMAT_BYTES_MAX
, FORMAT_TIMESPAN_MAX
)];
595 if (!terminal_is_dumb())
596 fputs(ANSI_HOME_CLEAR
, stdout
);
598 array
= newa(Group
*, hashmap_size(a
));
600 HASHMAP_FOREACH(g
, a
, i
)
601 if (g
->n_tasks_valid
|| g
->cpu_valid
|| g
->memory_valid
|| g
->io_valid
)
604 typesafe_qsort(array
, n
, group_compare
);
606 /* Find the longest names in one run */
607 for (j
= 0; j
< n
; j
++) {
608 unsigned cputlen
, pathtlen
;
610 format_timespan(buffer
, sizeof(buffer
), (usec_t
) (array
[j
]->cpu_usage
/ NSEC_PER_USEC
), 0);
611 cputlen
= strlen(buffer
);
612 maxtcpu
= MAX(maxtcpu
, cputlen
);
614 pathtlen
= strlen(array
[j
]->path
);
615 maxtpath
= MAX(maxtpath
, pathtlen
);
618 if (arg_cpu_type
== CPU_PERCENT
)
619 xsprintf(buffer
, "%6s", "%CPU");
621 xsprintf(buffer
, "%*s", maxtcpu
, "CPU Time");
628 const char *on
, *off
;
630 path_columns
= columns() - 36 - strlen(buffer
);
631 if (path_columns
< 10)
634 on
= ansi_highlight_underline();
635 off
= ansi_underline();
637 printf("%s%s%-*s%s %s%7s%s %s%s%s %s%8s%s %s%8s%s %s%8s%s%s\n",
639 arg_order
== ORDER_PATH
? on
: "", path_columns
, "Control Group",
640 arg_order
== ORDER_PATH
? off
: "",
641 arg_order
== ORDER_TASKS
? on
: "", arg_count
== COUNT_PIDS
? "Tasks" : arg_count
== COUNT_USERSPACE_PROCESSES
? "Procs" : "Proc+",
642 arg_order
== ORDER_TASKS
? off
: "",
643 arg_order
== ORDER_CPU
? on
: "", buffer
,
644 arg_order
== ORDER_CPU
? off
: "",
645 arg_order
== ORDER_MEMORY
? on
: "", "Memory",
646 arg_order
== ORDER_MEMORY
? off
: "",
647 arg_order
== ORDER_IO
? on
: "", "Input/s",
648 arg_order
== ORDER_IO
? off
: "",
649 arg_order
== ORDER_IO
? on
: "", "Output/s",
650 arg_order
== ORDER_IO
? off
: "",
653 path_columns
= maxtpath
;
655 for (j
= 0; j
< n
; j
++) {
656 _cleanup_free_
char *ellipsized
= NULL
;
659 if (on_tty() && j
+ 6 > rows
)
664 path
= empty_to_root(g
->path
);
665 ellipsized
= ellipsize(path
, path_columns
, 33);
666 printf("%-*s", path_columns
, ellipsized
?: path
);
668 if (g
->n_tasks_valid
)
669 printf(" %7" PRIu64
, g
->n_tasks
);
673 if (arg_cpu_type
== CPU_PERCENT
) {
675 printf(" %6.1f", g
->cpu_fraction
*100);
679 printf(" %*s", maxtcpu
, format_timespan(buffer
, sizeof(buffer
), (usec_t
) (g
->cpu_usage
/ NSEC_PER_USEC
), 0));
681 printf(" %8s", maybe_format_bytes(buffer
, sizeof(buffer
), g
->memory_valid
, g
->memory
));
682 printf(" %8s", maybe_format_bytes(buffer
, sizeof(buffer
), g
->io_valid
, g
->io_input_bps
));
683 printf(" %8s", maybe_format_bytes(buffer
, sizeof(buffer
), g
->io_valid
, g
->io_output_bps
));
689 static int help(void) {
690 _cleanup_free_
char *link
= NULL
;
693 r
= terminal_urlify_man("systemd-cgtop", "1", &link
);
697 printf("%s [OPTIONS...] [CGROUP]\n\n"
698 "Show top control groups by their resource usage.\n\n"
699 " -h --help Show this help\n"
700 " --version Show package version\n"
701 " -p --order=path Order by path\n"
702 " -t --order=tasks Order by number of tasks/processes\n"
703 " -c --order=cpu Order by CPU load (default)\n"
704 " -m --order=memory Order by memory load\n"
705 " -i --order=io Order by IO load\n"
706 " -r --raw Provide raw (not human-readable) numbers\n"
707 " --cpu=percentage Show CPU usage as percentage (default)\n"
708 " --cpu=time Show CPU usage as time\n"
709 " -P Count userspace processes instead of tasks (excl. kernel)\n"
710 " -k Count all processes instead of tasks (incl. kernel)\n"
711 " --recursive=BOOL Sum up process count recursively\n"
712 " -d --delay=DELAY Delay between updates\n"
713 " -n --iterations=N Run for N iterations before exiting\n"
714 " -1 Shortcut for --iterations=1\n"
715 " -b --batch Run in batch mode, accepting no input\n"
716 " --depth=DEPTH Maximum traversal depth (default: %u)\n"
717 " -M --machine= Show container\n"
718 "\nSee the %s for details.\n"
719 , program_invocation_short_name
727 static int parse_argv(int argc
, char *argv
[]) {
736 static const struct option options
[] = {
737 { "help", no_argument
, NULL
, 'h' },
738 { "version", no_argument
, NULL
, ARG_VERSION
},
739 { "delay", required_argument
, NULL
, 'd' },
740 { "iterations", required_argument
, NULL
, 'n' },
741 { "batch", no_argument
, NULL
, 'b' },
742 { "raw", no_argument
, NULL
, 'r' },
743 { "depth", required_argument
, NULL
, ARG_DEPTH
},
744 { "cpu", optional_argument
, NULL
, ARG_CPU_TYPE
},
745 { "order", required_argument
, NULL
, ARG_ORDER
},
746 { "recursive", required_argument
, NULL
, ARG_RECURSIVE
},
747 { "machine", required_argument
, NULL
, 'M' },
756 while ((c
= getopt_long(argc
, argv
, "hptcmin:brd:kPM:1", options
, NULL
)) >= 0)
768 if (streq(optarg
, "time"))
769 arg_cpu_type
= CPU_TIME
;
770 else if (streq(optarg
, "percentage"))
771 arg_cpu_type
= CPU_PERCENT
;
773 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
774 "Unknown argument to --cpu=: %s",
777 arg_cpu_type
= CPU_TIME
;
782 r
= safe_atou(optarg
, &arg_depth
);
784 return log_error_errno(r
, "Failed to parse depth parameter '%s': %m", optarg
);
789 r
= parse_sec(optarg
, &arg_delay
);
791 return log_error_errno(r
, "Failed to parse delay parameter '%s': %m", optarg
);
793 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
794 "Invalid delay parameter '%s'",
800 r
= safe_atou(optarg
, &arg_iterations
);
802 return log_error_errno(r
, "Failed to parse iterations parameter '%s': %m", optarg
);
819 arg_order
= ORDER_PATH
;
823 arg_order
= ORDER_TASKS
;
827 arg_order
= ORDER_CPU
;
831 arg_order
= ORDER_MEMORY
;
835 arg_order
= ORDER_IO
;
839 if (streq(optarg
, "path"))
840 arg_order
= ORDER_PATH
;
841 else if (streq(optarg
, "tasks"))
842 arg_order
= ORDER_TASKS
;
843 else if (streq(optarg
, "cpu"))
844 arg_order
= ORDER_CPU
;
845 else if (streq(optarg
, "memory"))
846 arg_order
= ORDER_MEMORY
;
847 else if (streq(optarg
, "io"))
848 arg_order
= ORDER_IO
;
850 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
851 "Invalid argument to --order=: %s",
856 arg_count
= COUNT_ALL_PROCESSES
;
860 arg_count
= COUNT_USERSPACE_PROCESSES
;
864 r
= parse_boolean(optarg
);
866 return log_error_errno(r
, "Failed to parse --recursive= argument '%s': %m", optarg
);
869 arg_recursive_unset
= r
== 0;
873 arg_machine
= optarg
;
880 assert_not_reached("Unhandled option");
883 if (optind
== argc
- 1)
884 arg_root
= argv
[optind
];
885 else if (optind
< argc
)
886 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
887 "Too many arguments.");
892 static const char* counting_what(void) {
893 if (arg_count
== COUNT_PIDS
)
895 else if (arg_count
== COUNT_ALL_PROCESSES
)
896 return "all processes (incl. kernel)";
898 return "userspace processes (excl. kernel)";
901 DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(group_hash_ops
, char, path_hash_func
, path_compare_func
, Group
, group_free
);
903 static int run(int argc
, char *argv
[]) {
904 _cleanup_hashmap_free_ Hashmap
*a
= NULL
, *b
= NULL
;
905 unsigned iteration
= 0;
906 usec_t last_refresh
= 0;
907 bool quit
= false, immediate_refresh
= false;
908 _cleanup_free_
char *root
= NULL
;
912 log_show_color(true);
913 log_parse_environment();
916 r
= parse_argv(argc
, argv
);
920 r
= cg_mask_supported(&mask
);
922 return log_error_errno(r
, "Failed to determine supported controllers: %m");
924 arg_count
= (mask
& CGROUP_MASK_PIDS
) ? COUNT_PIDS
: COUNT_USERSPACE_PROCESSES
;
926 if (arg_recursive_unset
&& arg_count
== COUNT_PIDS
)
927 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
928 "Non-recursive counting is only supported when counting processes, not tasks. Use -P or -k.");
930 r
= show_cgroup_get_path_and_warn(arg_machine
, arg_root
, &root
);
932 return log_error_errno(r
, "Failed to get root control group path: %m");
933 log_debug("CGroup path: %s", root
);
935 a
= hashmap_new(&group_hash_ops
);
936 b
= hashmap_new(&group_hash_ops
);
940 signal(SIGWINCH
, columns_lines_cache_reset
);
942 if (arg_iterations
== (unsigned) -1)
943 arg_iterations
= on_tty() ? 0 : 1;
948 char h
[FORMAT_TIMESPAN_MAX
];
950 t
= now(CLOCK_MONOTONIC
);
952 if (t
>= last_refresh
+ arg_delay
|| immediate_refresh
) {
954 r
= refresh(root
, a
, b
, iteration
++);
956 return log_error_errno(r
, "Failed to refresh: %m");
962 immediate_refresh
= false;
967 if (arg_iterations
&& iteration
>= arg_iterations
)
970 if (!on_tty()) /* non-TTY: Empty newline as delimiter between polls */
975 (void) usleep(last_refresh
+ arg_delay
- t
);
977 r
= read_one_char(stdin
, &key
, last_refresh
+ arg_delay
- t
, NULL
);
981 return log_error_errno(r
, "Couldn't read key: %m");
984 if (on_tty()) { /* TTY: Clear any user keystroke */
985 fputs("\r \r", stdout
);
995 immediate_refresh
= true;
1003 arg_order
= ORDER_PATH
;
1007 arg_order
= ORDER_TASKS
;
1011 arg_order
= ORDER_CPU
;
1015 arg_order
= ORDER_MEMORY
;
1019 arg_order
= ORDER_IO
;
1023 arg_cpu_type
= arg_cpu_type
== CPU_TIME
? CPU_PERCENT
: CPU_TIME
;
1027 arg_count
= arg_count
!= COUNT_ALL_PROCESSES
? COUNT_ALL_PROCESSES
: COUNT_PIDS
;
1028 fprintf(stdout
, "\nCounting: %s.", counting_what());
1034 arg_count
= arg_count
!= COUNT_USERSPACE_PROCESSES
? COUNT_USERSPACE_PROCESSES
: COUNT_PIDS
;
1035 fprintf(stdout
, "\nCounting: %s.", counting_what());
1041 if (arg_count
== COUNT_PIDS
)
1042 fprintf(stdout
, "\n\aCannot toggle recursive counting, not available in task counting mode.");
1044 arg_recursive
= !arg_recursive
;
1045 fprintf(stdout
, "\nRecursive process counting: %s", yes_no(arg_recursive
));
1052 if (arg_delay
< USEC_PER_SEC
)
1053 arg_delay
+= USEC_PER_MSEC
*250;
1055 arg_delay
+= USEC_PER_SEC
;
1057 fprintf(stdout
, "\nIncreased delay to %s.", format_timespan(h
, sizeof(h
), arg_delay
, 0));
1063 if (arg_delay
<= USEC_PER_MSEC
*500)
1064 arg_delay
= USEC_PER_MSEC
*250;
1065 else if (arg_delay
< USEC_PER_MSEC
*1250)
1066 arg_delay
-= USEC_PER_MSEC
*250;
1068 arg_delay
-= USEC_PER_SEC
;
1070 fprintf(stdout
, "\nDecreased delay to %s.", format_timespan(h
, sizeof(h
), arg_delay
, 0));
1078 #define ON ANSI_HIGHLIGHT
1079 #define OFF ANSI_NORMAL
1082 "\t<" ON
"p" OFF
"> By path; <" ON
"t" OFF
"> By tasks/procs; <" ON
"c" OFF
"> By CPU; <" ON
"m" OFF
"> By memory; <" ON
"i" OFF
"> By I/O\n"
1083 "\t<" ON
"+" OFF
"> Inc. delay; <" ON
"-" OFF
"> Dec. delay; <" ON
"%%" OFF
"> Toggle time; <" ON
"SPACE" OFF
"> Refresh\n"
1084 "\t<" ON
"P" OFF
"> Toggle count userspace processes; <" ON
"k" OFF
"> Toggle count all processes\n"
1085 "\t<" ON
"r" OFF
"> Count processes recursively; <" ON
"q" OFF
"> Quit");
1092 fprintf(stdout
, "\nUnknown key '\\x%x'. Ignoring.", key
);
1094 fprintf(stdout
, "\nUnknown key '%c'. Ignoring.", key
);
1104 DEFINE_MAIN_FUNCTION(run
);