From: Ben Gras Date: Fri, 23 Jun 2006 11:59:20 +0000 (+0000) Subject: New option -E for ps that prints endpoint numbers instead of pids. X-Git-Tag: v3.1.3~296 X-Git-Url: http://zhaoyanbai.com/repos/icons/debian/static/doxygen.log?a=commitdiff_plain;h=3ffa1684ae6b47bbdd7e9f774d5348e9094617c3;p=minix.git New option -E for ps that prints endpoint numbers instead of pids. --- diff --git a/commands/ps/ps.c b/commands/ps/ps.c index a7a16b191..51cdd2376 100644 --- a/commands/ps/ps.c +++ b/commands/ps/ps.c @@ -179,7 +179,7 @@ _PROTOTYPE(char *prrecv, (struct pstat *bufp )); _PROTOTYPE(void disaster, (int sig )); _PROTOTYPE(int main, (int argc, char *argv [])); _PROTOTYPE(char *get_args, (struct pstat *bufp )); -_PROTOTYPE(int pstat, (int p_nr, struct pstat *bufp )); +_PROTOTYPE(int pstat, (int p_nr, struct pstat *bufp, int Eflag )); _PROTOTYPE(int addrread, (int fd, phys_clicks base, vir_bytes addr, char *buf, int nbytes )); _PROTOTYPE(void usage, (char *pname )); @@ -280,6 +280,7 @@ char *argv[]; int opt_all = FALSE; /* -a */ int opt_long = FALSE; /* -l */ int opt_notty = FALSE; /* -x */ + int opt_endpoint = FALSE; /* -E */ char *ke_path; /* paths of kernel, */ char *mm_path; /* mm, */ char *fs_path; /* and fs used in ps -U */ @@ -297,6 +298,7 @@ char *argv[]; if (opt[0] == '-') opt++; while (*opt != 0) switch (*opt++) { case 'a': opt_all = TRUE; break; + case 'E': opt_endpoint = TRUE; break; case 'e': opt_all = opt_notty = TRUE; break; case 'f': case 'l': opt_long = TRUE; break; @@ -352,7 +354,7 @@ char *argv[]; /* Now loop through process table and handle each entry */ printf("%s", opt_long ? L_HEADER : S_HEADER); for (i = -nr_tasks; i < nr_procs; i++) { - if (pstat(i, &buf) != -1 && + if (pstat(i, &buf, opt_endpoint) != -1 && (opt_all || buf.ps_euid == uid || buf.ps_ruid == uid) && (opt_notty || majdev(buf.ps_dev) == TTY_MAJ)) { if (buf.ps_pid == 0 && i != PM_PROC_NR) { @@ -458,9 +460,10 @@ struct pstat *bufp; /* Pstat collects info on process number p_nr and returns it in buf. * It is assumed that tasks do not have entries in fproc/mproc. */ -int pstat(p_nr, bufp) +int pstat(p_nr, bufp, endpoints) int p_nr; struct pstat *bufp; +int endpoints; { int p_ki = p_nr + nr_tasks; /* kernel proc index */ @@ -483,7 +486,8 @@ struct pstat *bufp; if (p_nr >= 0) { bufp->ps_ruid = ps_mproc[p_nr].mp_realuid; bufp->ps_euid = ps_mproc[p_nr].mp_effuid; - bufp->ps_pid = ps_mproc[p_nr].mp_pid; + if(endpoints) bufp->ps_pid = ps_proc[p_ki].p_endpoint; + else bufp->ps_pid = ps_mproc[p_nr].mp_pid; bufp->ps_ppid = ps_mproc[ps_mproc[p_nr].mp_parent].mp_pid; bufp->ps_pgrp = ps_mproc[p_nr].mp_procgrp; bufp->ps_mflags = ps_mproc[p_nr].mp_flags; diff --git a/man/man1/ps.1 b/man/man1/ps.1 index 839d20a78..fa977bbf6 100644 --- a/man/man1/ps.1 +++ b/man/man1/ps.1 @@ -2,7 +2,7 @@ .SH NAME ps \- process status .SH SYNOPSIS -\fBps \fR[\fR[\fB\-\fR]\fBalx\fR] +\fBps \fR[\fR[\fB\-\fR]\fBalxE\fR] .br .de FL .TP @@ -18,10 +18,11 @@ ps \- process status .FL "\-a" "Print all processes with controlling terminals" .FL "\-l" "Give long listing" .FL "\-x" "Include processes without a terminal" +.FL "\-E" "Print kernel endpoint numbers where pids are normally printed" .SH EXAMPLES .EX "ps " "Show user's own processes in short format" -.EX "ps \-axl" "Print all processes and tasks in long format" -.EX "ps \axl" "Same -- the '\-' is optional" +.EX "ps \-axlE" "Print all processes and tasks in long format" +.EX "ps \axlE" "Same -- the '\-' is optional" .SH DESCRIPTION .PP \fIPs\fR prints the status of active processes. Normally only the caller's own