summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-07-08 21:01:42 +0200
committerLennart Poettering <lennart@poettering.net>2010-07-08 21:01:42 +0200
commitfa776d8e962da9d90459e2f3e86a2a0c6366ee12 (patch)
treec75cc3cb9343a53d55741983c317ee8d414f8f0a /src/util.c
parentab35fb1bc68625c891a19a66473a9c40ca12e69d (diff)
cgls: beef up control group dumping and introduce cgls tool
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 6cbc7ce477..2e5827f32d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -609,6 +609,9 @@ int get_process_cmdline(pid_t pid, size_t max_length, char **line) {
fclose(f);
+ if (r[0] == 0)
+ return get_process_name(pid, line);
+
*line = r;
return 0;
}
@@ -2798,6 +2801,30 @@ char **replace_env_argv(char **argv, char **env) {
return r;
}
+int columns(void) {
+ static __thread int parsed_columns = 0;
+ const char *e;
+
+ if (parsed_columns > 0)
+ return parsed_columns;
+
+ if ((e = getenv("COLUMNS")))
+ parsed_columns = atoi(e);
+
+ if (parsed_columns <= 0) {
+ struct winsize ws;
+ zero(ws);
+
+ if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) >= 0)
+ parsed_columns = ws.ws_col;
+ }
+
+ if (parsed_columns <= 0)
+ parsed_columns = 80;
+
+ return parsed_columns;
+}
+
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",