On Friday 05 June 2009 09:12:08 Paul B. Mahol wrote: > On 6/5/09, Yuri <y...@rawbw.com> wrote: > > How can I see processes in a hierarchical way? > > http://lists.freebsd.org/pipermail/svn-src-head/2009-May/006912.html > > or pstree from ports.
And if in a jail, you can use the patch below to add jail support via -j switch. -- Mel --- pstree.c.orig 2007-10-26 11:39:50.000000000 -0800 +++ pstree.c 2008-09-20 00:30:53.000000000 -0800 @@ -189,7 +189,7 @@ { "qq", "qw", "`", "q", "t", "x", "m", "\016", "\017", "\033(B\033)0" } /*Vt100*/ }, *C; -int MyPid, NProc, Columns, RootPid; +int MyPid, NProc, Columns, RootPid, jFlag; short showall = TRUE, soption = FALSE, Uoption = FALSE; char *name = "", *str = NULL, *Progname; long ipid = -1; @@ -464,6 +464,27 @@ exit(1); } + /* If this is a FreeBSD jail(8), create a fake root process 'jailinit', which + * serves as starting point for the tree. */ + if( jFlag ) + { + P = realloc(P, (i+1) * sizeof(struct Proc)); + if (P == NULL) { + fprintf(stderr, "Problems with realloc.\n"); + exit(1); + } + memset(&P[i], 0, sizeof(*P)); + P[i].uid = 0; + (void)strncpy(P[i].name, "root", sizeof(P[i].name)); + P[i].pid = 1; + P[i].ppid = 0; + P[i].pgid = 1; + P[i].thcount = 1; + (void)strncpy(P[i].cmd, "/sbin/jailinit", sizeof(P[i].cmd)); + P[i].parent = P[i].child = P[i].sister = -1; + P[i].print = FALSE; + i++; + } while (NULL != fgets(line, MAXLINE, tn)) { int len, num; len = strlen(line); @@ -728,6 +749,7 @@ " -f file read input from <file> (- is stdin) instead of running\n" " \"%s\"\n" " -g n use graphics chars for tree. n=1: IBM-850, n=2: VT100\n" + " -j Assume running in a FreeBSD jail (no root process)\n" " -l n print tree to n level deep\n" " -u user show only branches containing processes of <user>\n" " -U don't show branches containing only root processes\n" @@ -756,7 +778,7 @@ Progname = strrchr(argv[0],'/'); Progname = (NULL == Progname) ? argv[0] : Progname + 1; - while ((ch = getopt(argc, argv, "df:g:hl:p:s:u:Uw?")) != EOF) + while ((ch = getopt(argc, argv, "df:g:hjl:p:s:u:Uw?")) != EOF) switch(ch) { /*case 'a': align = TRUE; @@ -778,6 +800,9 @@ } C = &TreeChars[graph]; break; + case 'j' : + jFlag = 1; + break; case 'l': /* LOPTION */ maxLdepth = atoi(optarg); /* LOPTION */ if(maxLdepth < 1) maxLdepth = 1; /* LOPTION */ _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"