X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Matthew Woehlke Subject: Re: display ps command line parameters Date: Mon, 30 Apr 2007 18:01:42 -0500 Lines: 91 Message-ID: References: <4edba06c76Andy AT jet-net DOT co DOT uk> <045201c78b52$9f46e0b0$2e08a8c0 AT CAM DOT ARTIMI DOT COM> <045a01c78b55$04f20780$2e08a8c0 AT CAM DOT ARTIMI DOT COM> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000902040704050809040004" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.4.0 In-Reply-To: <045a01c78b55$04f20780$2e08a8c0@CAM.ARTIMI.COM> X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --------------000902040704050809040004 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Dave Korn wrote: > On 30 April 2007 19:23, Matthew Woehlke wrote: > >> Dave Korn wrote: >>> On 30 April 2007 18:48, Matthew Woehlke wrote: >>> >>>> um... and since Cygwin has this information, doesn't this mean that 'ps' >>>> is missing a feature that is standard to pretty much every other *nix >>>> implementation of 'ps'? (I don't have a POSIX standard handy >>> Yes you do: open browser, google "posix opengroup". Vol.2, "Shell and >>> utilities", part 4: Utilities: takes us to >> ...and am too lazy to look. :-) Anyway, since the information is >> available, and most other *nix's 'ps' provides it, any reason Cygwin's >> 'ps' shouldn't do the same? > > I believe you can probably guess the answer to this one... particularly if I > tell you it starts with "P" and ends with "TC" :) Ok... Here is a P for you to TD* (* D="Decline") :-) -- Matthew If you believe you received this e-mail in error, you are probably sadly mistaken, but if not, aren't you lucky? --------------000902040704050809040004 Content-Type: text/x-patch; name="ps.cc.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ps.cc.diff" --- ps.cc.orig 2007-04-30 17:33:46.245634000 -0500 +++ ps.cc 2007-04-30 17:57:22.907472200 -0500 @@ -18,6 +18,7 @@ #include #include #include +#include static const char version[] = "$Revision: 1.11 $"; static char *prog_name; @@ -253,7 +254,7 @@ const char *ftitle = " UID PID PPID TTY STIME COMMAND\n"; const char *ffmt = "%8.8s%8d%8d%4s%10s %s\n"; const char *ltitle = " PID PPID PGID WINPID TTY UID STIME COMMAND\n"; - const char *lfmt = "%c %7d %7d %7d %10u %4s %4u %8s %s\n"; + const char *lfmt = "%c %7d %7d %7d %10u %4s %4u %8s %s"; char ch; aflag = lflag = fflag = sflag = 0; @@ -405,11 +406,27 @@ printf (ffmt, uname, p->pid, p->ppid, ttynam (p->ctty), start_time (p), pname); else if (lflag) - printf (lfmt, status, p->pid, p->ppid, p->pgid, - p->dwProcessId, ttynam (p->ctty), - p->version >= EXTERNAL_PINFO_VERSION_32_BIT ? p->uid32 : p->uid, - start_time (p), pname); - + { + printf (lfmt, status, p->pid, p->ppid, p->pgid, + p->dwProcessId, ttynam (p->ctty), + p->version >= EXTERNAL_PINFO_VERSION_32_BIT ? p->uid32 : p->uid, + start_time (p), pname); + if (p->ppid) + { + char procpath[MAX_PATH]; + FILE *f; + snprintf(procpath, MAX_PATH, "/proc/%u/cmdline", p->pid); + f = fopen(procpath, "rb"); + if (f) + { + int c = 1; + while (c != 0 && c != EOF) c = fgetc(f); + for (;c != EOF; c = fgetc(f)) printf("%c", c?c:' '); + fclose(f); + } + } + printf("\n"); + } } (void) cygwin_internal (CW_UNLOCK_PINFO); --------------000902040704050809040004 Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --------------000902040704050809040004--