From 238cdcd0896883250022f2e63dd71bdf946a07bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Mon, 7 Oct 2002 22:54:57 +0000 Subject: [PATCH] Added team filtering on argv[1] (R5.1 ps has this feature) git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1444 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/bin/ps.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/apps/bin/ps.c b/src/apps/bin/ps.c index 0308ae7a38..81388a61c1 100644 --- a/src/apps/bin/ps.c +++ b/src/apps/bin/ps.c @@ -5,11 +5,14 @@ * ChangeLog: * 04-26-2002 v1.0 * Initial. + * 10-08-2002 + * Added team name filtering (upon suggestion from Dano users :) * */ #include #include +#include #define SNOOZE_TIME 100000 @@ -27,11 +30,25 @@ int main(int argc, char **argv) char *thstate; char *states[] = {"run", "rdy", "msg", "zzz", "sus", "sem" }; system_info sysinfo; + char *string_to_match; // match this in team name + if (argc == 2) + string_to_match = argv[1]; puts(""); puts(PS_HEADER); puts(PS_SEP); while ((ret = get_next_team_info(&teamcookie, &teaminfo)) >= B_OK) { + if (string_to_match) { + char *p; + p = teaminfo.args; + if ((p = strchr(p, ' '))) + *p = '\0'; /* remove arguments, keep only argv[0] */ + p = strrchr(teaminfo.args, '/'); /* forget the path */ + if (p == NULL) + p = teaminfo.args; + if (strstr(p, string_to_match) == NULL) + continue; + } printf("%s (team %d) (uid %d) (gid %d)\n", teaminfo.args, teaminfo.team, teaminfo.uid, teaminfo.gid); thcookie = 0; while ((ret = get_next_thread_info(teaminfo.team, &thcookie, &thinfo)) >= B_OK) {