Re: display ps command line parameters

2007-05-01 Thread Christopher Faylor
On Tue, May 01, 2007 at 10:41:19AM +0100, [EMAIL PROTECTED] wrote:
 An alternative would be to parse /proc/PID/cmdline. 
I think I'll use Tony's solution, as I don't have pstree available on my
development or live Cygwin installation. This would be quicker as I can
use it straight out of the box.

I was looking for exactly something like the cmdline file yesterday!

It seems rather silly to parse /proc/PID/cmdline when you could just use
procps.

cgf

--
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/



Re: display ps command line parameters

2007-05-01 Thread Igor Peshansky
On Tue, 1 May 2007, [EMAIL PROTECTED] wrote:

 All,
 Thanks for your replies.

  An alternative would be to parse /proc/PID/cmdline.

 I think I'll use Tony's solution, as I don't have pstree available on my
 development or live Cygwin installation. This would be quicker as I can
 use it straight out of the box.

 I was looking for exactly something like the cmdline file yesterday!

http://cygwin.com/ml/cygwin/2007-04/msg00821.html
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_Igor Peshansky, Ph.D. (name changed!)
 |,4-  ) )-,_. ,\ (  `'-'   old name: Igor Pechtchanski
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Freedom is just another word for nothing left to lose...  -- Janis Joplin

--
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/



display ps command line parameters

2007-04-30 Thread [EMAIL PROTECTED]
Hi all,

I'm trying to get parameters entered at the Cygwin command line to appear on
my ps command, and failing miserably!

i.e. I'm running the following process at the command line:

  program parameter1

In ps -s I get something like:

 PID  TTYSTIME COMMAND
1234  con 09:00:00 /path/program

... but I'd like to be able to pick up the parameter1. So far as I can see
it other ps commands on Unix have an -o args option. I've tried every
option that seems to be available in Cygwin ps (v 1.11), but cannot get past
this wall.

Is there a way of doing this through ps (or an alternative) in Cygwin?

Thanks in anticipation
Andy Burgess

-- 
  _ __   __
//_  /  /| /_  /  /...Your friendly computer professionals
 __//__ /  / |/__ /  / web : jet-net.co.uk
/ phone: 01256 819531 mobile : 07770 808843

--
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/



RE: display ps command line parameters

2007-04-30 Thread Dave Korn
On 30 April 2007 12:36, [EMAIL PROTECTED] wrote:

 Hi all,
 
 I'm trying to get parameters entered at the Cygwin command line to appear on
 my ps command, and failing miserably!

 Is there a way of doing this through ps (or an alternative) in Cygwin?

  If it doesn't say it in ps --help or man ps, it doesn't do it.




cheers,
  DaveK
-- 
Can't think of a witty .sigline today


--
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/



Re: display ps command line parameters

2007-04-30 Thread Michael Hoffman

[EMAIL PROTECTED] wrote:

Hi all,

I'm trying to get parameters entered at the Cygwin command line to appear on
my ps command, and failing miserably!

i.e. I'm running the following process at the command line:

  program parameter1

In ps -s I get something like:

 PID  TTYSTIME COMMAND
1234  con 09:00:00 /path/program

... but I'd like to be able to pick up the parameter1. So far as I can see
it other ps commands on Unix have an -o args option. I've tried every
option that seems to be available in Cygwin ps (v 1.11), but cannot get past
this wall.

Is there a way of doing this through ps (or an alternative) in Cygwin?


I use pstree -a.


--
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/



Re: display ps command line parameters

2007-04-30 Thread Tony Richardson
Andy at Jet-Net Andy at jet-net.co.uk writes:
 In ps -s I get something like:
 
  PID  TTYSTIME COMMAND
 1234  con 09:00:00 /path/program
 
 Is there a way of doing this through ps (or an alternative) in Cygwin?

An alternative would be to parse /proc/PID/cmdline.  Arguments are
separated by null bytes.

Tony Richardson





--
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/



Re: display ps command line parameters

2007-04-30 Thread Igor Peshansky
On Mon, 30 Apr 2007, [EMAIL PROTECTED] wrote:

 Hi all,

 I'm trying to get parameters entered at the Cygwin command line to
 appear on my ps command, and failing miserably!

 i.e. I'm running the following process at the command line:

   program parameter1

 In ps -s I get something like:

  PID  TTYSTIME COMMAND
 1234  con 09:00:00 /path/program

 ... but I'd like to be able to pick up the parameter1. So far as I can see
 it other ps commands on Unix have an -o args option. I've tried every
 option that seems to be available in Cygwin ps (v 1.11), but cannot get past
 this wall.

 Is there a way of doing this through ps (or an alternative) in Cygwin?

Try 'procps'.
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_Igor Peshansky, Ph.D. (name changed!)
 |,4-  ) )-,_. ,\ (  `'-'   old name: Igor Pechtchanski
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Freedom is just another word for nothing left to lose...  -- Janis Joplin

--
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/



Re: display ps command line parameters

2007-04-30 Thread Matthew Woehlke

Tony Richardson wrote:

Andy at Jet-Net Andy at jet-net.co.uk writes:

In ps -s I get something like:

 PID  TTYSTIME COMMAND
1234  con 09:00:00 /path/program

Is there a way of doing this through ps (or an alternative) in Cygwin?


An alternative would be to parse /proc/PID/cmdline.  Arguments are
separated by null bytes.


cat /proc/$pid/cmdline | xargs -0 echo

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, but I 
wonder if this is an unnecessary POSIX violation?)


--
Matthew
If you believe you received this e-mail in error, you are probably sadly 
mistaken, but if not, aren't you lucky?



--
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/



RE: display ps command line parameters

2007-04-30 Thread Dave Korn
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

http://www.opengroup.org/onlinepubs/009695399/utilities/ps.html

which is pretty lax about requirements:

 he args format specifier is allowed to produce a truncated version of the
command arguments. In some implementations, this information is no longer
available when the ps utility is executed. 

 The normative text is reworded to avoid use of the term must for
application requirements. 


cheers,
  DaveK
-- 
Can't think of a witty .sigline today


--
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/



Re: display ps command line parameters

2007-04-30 Thread Matthew Woehlke

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?


--
Matthew
If you believe you received this e-mail in error, you are probably sadly 
mistaken, but if not, aren't you lucky?



--
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/



RE: display ps command line parameters

2007-04-30 Thread Dave Korn
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  :)


cheers,
  DaveK
-- 
Can't think of a witty .sigline today


--
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/



Re: display ps command line parameters

2007-04-30 Thread Matthew Woehlke

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?
--- 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 sys/cygwin.h
 #include tlhelp32.h
 #include psapi.h
+#include sys/stat.h

 static const char version[] = $Revision: 1.11 $;
 static char *prog_name;
@@ -253,7 +254,7 @@
   const char *ftitle =  UID PIDPPID TTY STIME COMMAND\n;
   const char *ffmt   = %8.8s%8d%8d%4s%10s %s\n;
   const char *ltitle =   PIDPPIDPGID WINPID  TTY  UIDSTIME 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);


--
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/

Re: display ps command line parameters

2007-04-30 Thread Matthew Woehlke

Matthew Woehlke wrote:

Dave Korn wrote:

On 30 April 2007 19:23, Matthew Woehlke wrote:

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) :-)


As I was saying... I clearly put the code in the wrong place, because 
'ps' tells me args and 'ps -f' does not. So it needs some work... :-)


--
Matthew
If you believe you received this e-mail in error, you are probably sadly 
mistaken, but if not, aren't you lucky?



--
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/