[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] pstree: Pfadnamen gestrippt



From 224a2985477fae77a98995973c653e21f74de182 Mon Sep 17 00:00:00 2001
From: Alexander H. Kluth <hartmut@xxxxxxxxxx>
Date: Wed, 9 Dec 2009 10:02:51 +0100
Subject: [PATCH] pstree: Pfade gestrippt

+ pstree.c: Analog zu ps.c die Pfade vor den Prozessen gestriptt

Signed-off-by: Alexander H. Kluth <hartmut@xxxxxxxxxx>
---
 src/modules/c/shell/cmds/pstree.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/src/modules/c/shell/cmds/pstree.c b/src/modules/c/shell/cmds/pstree.c
index d6f63dd..6200d26 100644
--- a/src/modules/c/shell/cmds/pstree.c
+++ b/src/modules/c/shell/cmds/pstree.c
@@ -35,6 +35,7 @@

 #include "stdlib.h"
 #include "stdio.h"
+#include "string.h"
 #include "syscall.h"
 #include "unistd.h"
 #include <lost/config.h>
@@ -68,16 +69,30 @@ void pstree_display_usage()
 void pstree_show_children(pid_t pid, byte depth)
 {
     dword i, j;
+	char *temp, *process;
+	char copied_cmdline[255];

     for (i = 0; i < task_info->task_count; i++) {
+		strncpy(copied_cmdline, task_info->tasks[i].cmdline, 255);
+
+		process = strtok((char*)task_info->tasks[i].cmdline, " ");
+		process = strrchr(process, '/');
+
+		if ((temp = strchr(copied_cmdline, ' '))) {
+			strcat(process, temp);
+		}
+
         if (task_info->tasks[i].parent_pid == pid) {
             for (j = 0; j < depth; j++) {
                 printf("   ");
             }

-            printf("%s\n", task_info->tasks[i].cmdline);
+            printf("- %s\n", ++process);

             pstree_show_children(task_info->tasks[i].pid, depth + 1);
         }
+
+		process = NULL;
+		temp = NULL;
     }
 }
--
1.6.5.1.1367.gcd48