[systemd-commits] 2 commits - src/systemctl.c
Lennart Poettering
lennart at kemper.freedesktop.org
Mon Jul 5 20:55:48 PDT 2010
src/systemctl.c | 43 +++++++++++++++++++++++++++----------------
1 file changed, 27 insertions(+), 16 deletions(-)
New commits:
commit fc6071bfb38a118fd059e6f86750dfcf9580fd31
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Jul 6 05:55:41 2010 +0200
systemctl: don't use UTF directly
diff --git a/src/systemctl.c b/src/systemctl.c
index 6977f85..9b88da1 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -951,7 +951,7 @@ static void show_cgroup(const char *name) {
if (!f)
return;
- printf("\t\t â\n");
+ printf("\t\t \342\224\202\n");
while (!feof(f)) {
unsigned long ul;
@@ -965,7 +965,7 @@ static void show_cgroup(const char *name) {
if (last > 0) {
char *t = NULL;
get_process_cmdline(last, 60, &t);
- printf("\t\t â %lu %s\n", (unsigned long) last, strna(t));
+ printf("\t\t \342\224\234 %lu %s\n", (unsigned long) last, strna(t));
free(t);
}
@@ -975,7 +975,7 @@ static void show_cgroup(const char *name) {
if (last > 0) {
char *t = NULL;
get_process_cmdline(last, 60, &t);
- printf("\t\t â %lu %s\n", (unsigned long) last, strna(t));
+ printf("\t\t \342\224\224 %lu %s\n", (unsigned long) last, strna(t));
free(t);
}
commit 5f75059770f5faacfd52596d1a612bffcdd87187
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Jul 6 05:38:12 2010 +0200
systemctl: fix parsing of cgroup contents
diff --git a/src/systemctl.c b/src/systemctl.c
index 73b0fc4..6977f85 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -935,9 +935,9 @@ finish:
}
static void show_cgroup(const char *name) {
- char *fn, *pids;
- int r;
- char *p;
+ char *fn;
+ FILE *f;
+ pid_t last = 0;
if (!startswith(name, "name=systemd:"))
return;
@@ -945,30 +945,41 @@ static void show_cgroup(const char *name) {
if (asprintf(&fn, "/cgroup/systemd/%s/tasks", name + 13) < 0)
return;
- r = read_one_line_file(fn, &pids);
+ f = fopen(fn, "r");
free(fn);
- if (r < 0)
+ if (!f)
return;
- p = pids;
- while (p[0]) {
- unsigned long ul;
- char *t = NULL;
+ printf("\t\t â\n");
- p += strspn(p, WHITESPACE);
+ while (!feof(f)) {
+ unsigned long ul;
- errno = 0;
- ul = strtoul(p, &p, 0);
- if (errno != 0 || ul <= 0)
+ if (fscanf(f, "%lu", &ul) != 1)
break;
- get_process_cmdline((pid_t) ul, 60, &t);
- printf("\t\t%lu %s\n", ul, strna(t));
+ if (ul <= 0)
+ continue;
+
+ if (last > 0) {
+ char *t = NULL;
+ get_process_cmdline(last, 60, &t);
+ printf("\t\t â %lu %s\n", (unsigned long) last, strna(t));
+ free(t);
+ }
+
+ last = (pid_t) ul;
+ }
+
+ if (last > 0) {
+ char *t = NULL;
+ get_process_cmdline(last, 60, &t);
+ printf("\t\t â %lu %s\n", (unsigned long) last, strna(t));
free(t);
}
- free(pids);
+ fclose(f);
}
typedef struct UnitStatusInfo {
More information about the systemd-commits
mailing list