4

Is there a way to get the full output from ps on Cygwin?

For instance, none of the following gives me the full wget shell line, just /usr/bin/wget:

$ ps -ef | grep wget
Administ    9844    7780 pty1     13:22:57 /usr/bin/wget
Administ    8036   12648 pty0     13:18:15 /usr/bin/wget
Administ    4832   11828 pty2     13:23:42 /usr/bin/wget

$ ps awx | grep wget
     9844    7780    9844      10264  pty1      197108 13:22:57 /usr/bin/wget
     8036   12648    8036      10060  pty0      197108 13:18:15 /usr/bin/wget
     4832   11828    4832      10780  pty2      197108 13:23:42 /usr/bin/wget

$ ps -p 9844 | cat
      PID    PPID    PGID     WINPID   TTY         UID    STIME COMMAND
     9844    7780    9844      10264  pty1      197108 13:22:57 /usr/bin/wget
2
  • Have you tried ps -efl? This is what I normally use for a long listing in Linux. Or you can use -o and specify the columns you want to see. I don't know if these options are available in Cygwin.
    – AFH
    Sep 6, 2017 at 10:57
  • Thanks @AFH: alas, (on Cygwin) ps -efl gives the same output as ps -ef.
    – boardrider
    Sep 8, 2017 at 9:59

3 Answers 3

4

As you can see from cygwin ps manual the command line is not reported.

It is however available under /proc/process_PID/cmdline

2

This prints all Cygwin processes and it's command line, however without spaces:

grep -a "" /proc/*/cmdline

-a tells grep to show content of binary files (cmdline is binary, not text)

"" tell to match to everything. You can replace it to the name of process you are interested

$ grep -a "" /proc/*/cmdline /proc/10236/cmdline:/usr/bin/mintty-i/Cygwin-Terminal.ico- /proc/11340/cmdline:-bash /proc/11672/cmdline:[email protected] ...

if you want to preserve spaces in command line, do this:

grep -a "" /proc/*/cmdline | xargs -0

0

The cygwin, MSYS and MSYS2 ps's are severely hampered. As a result I use several other aliases/functions to help out. For the command line, I specifically use a shell function named cmdl:

cmdl ()
{
    if [ $# -eq 0 ]; then
        cat /proc/$$/cmdline | tr '\0' ' '
    else
        while [ $# -gt 0 ]; do
            cat /proc/$1/cmdline | tr '\0' ' '
            echo
            shift
        done
    fi
    echo
}

Use cmdl to return the command line of the running process, or cmdl <pid>... to print the command line of the listed process id's (1 or more).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .