delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/11/18/20:24:22

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS
X-Spam-Check-By: sourceware.org
From: Haojun Bao <baohaojun AT gmail DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: CYGWIN_NT-5.1 1.7.0(0.214/5/3) ps (cygwin) 1.11 - how do I display the arguments to the processes?
References: <742340 DOT 79130 DOT qm AT web30808 DOT mail DOT mud DOT yahoo DOT com> <f275afc9b0711589dbc781439caea777 AT localhost>
Date: Thu, 19 Nov 2009 09:23:11 +0800
In-Reply-To: <f275afc9b0711589dbc781439caea777@localhost> (Chris January's message of "Wed, 18 Nov 2009 14:37:58 +0000")
Message-ID: <837htnb94w.fsf@gmail.com>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (cygwin)
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Chris January <chris AT atomice DOT net> writes:
>
> Install the procps package and then use the procps command.
>

You can also try WMIC which comes with Windows, on XP in my case.

If you need for e.g., PID/PPID/CMDLINE, especially if you need see
Windows native processes and if procps can't do that (I don't know if it
can or not), then you can use this script:

#!/bin/perl

## here, "</dev/null" needed because wmic.exe get confused if STDIN is a pipe 

$Processes=`wmic.exe path win32_process get CommandLine,ProcessId,ParentProcessId </dev/null`;
@Processes = split /\r*\n/, $Processes;

$Processes[0] =~ m/^(CommandLine.*)(ParentProcessId.*)(ProcessId.*)$/ or #the order of pid/ppid seems to be random with wmic?
    die "can't match the first line";

$\="\n";
printf "%9s%9s  %s\n", PID, PPID, COMMAND;
foreach (@Processes[1..$#Processes]) {
    m/^(.*?)\s*([0-9]+)\s*([0-9]+)\s*$/ or die "can't match $_";
    printf "%9d%9d  %s\n", $3, $2, $1;
}


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019