0

I installed Cygwin64 and tried its pgrep.exe tool (with admin privilege) as follows:

PS D:\cygwin64\bin> D:\cygwin64\bin\pgrep.exe svchost.exe
PS D:\cygwin64\bin> D:\cygwin64\bin\pgrep.exe svchost.exe -af
PS D:\cygwin64\bin> D:\cygwin64\bin\pgrep.exe -h

Usage:
 pgrep [options] <pattern>

Options:
 -d, --delimiter <string>  specify output delimiter
 -l, --list-name           list PID and process name
 -a, --list-full           list PID and full command line
 -v, --inverse             negates the matching
 -w, --lightweight         list all TID
 -c, --count               count of matching processes
 -f, --full                use full process name to match
 -g, --pgroup <PGID,...>   match listed process group IDs
 -G, --group <GID,...>     match real group IDs
 -i, --ignore-case         match case insensitively
 -n, --newest              select most recently started
 -o, --oldest              select least recently started
 -O, --older <seconds>     select where older than seconds
 -P, --parent <PPID,...>   match only child processes of the given parent
 -s, --session <SID,...>   match session IDs
 -t, --terminal <tty,...>  match by controlling terminal
 -u, --euid <ID,...>       match by effective IDs
 -U, --uid <ID,...>        match by real IDs
 -x, --exact               match exactly with the command name
 -F, --pidfile <file>      read PIDs from file
 -L, --logpidfile          fail if PID file is not locked
 -r, --runstates <state>   match runstates [D,S,Z,...]
 -A, --ignore-ancestors    exclude our ancestors from results
 --cgroup <grp,...>        match by cgroup v2 names
 --ns <PID>                match the processes that belong to the same
                           namespace as <pid>
 --nslist <ns,...>         list which namespaces will be considered for
                           the --ns option.
                           Available namespaces: ipc, mnt, net, pid, user, uts

 -h, --help     display this help and exit
 -V, --version  output version information and exit

For more details see pgrep(1).
PS D:\cygwin64\bin>

Seems pgrep.exe is running correctly but it fails to return the pid of svchost.exe.

D.J. Elkind
  • 101
  • 2
  • I don't think it is supposed to find anything that is not running above the cygwin layer. (It is the case for msys2, which is more or less a cygwin fork.) – Tom Yan Aug 29 '23 at 10:27
  • @TomYan ah you mean for pgrep under cgywin, it is only supposed to work with other processes within the cgywin "environment"? – D.J. Elkind Aug 29 '23 at 10:28
  • Yup, AFACIT. (You can try something like `ps aux` btw. Same story.) – Tom Yan Aug 29 '23 at 10:30
  • emmm this makes `pgrep` way less useful then... – D.J. Elkind Aug 29 '23 at 10:37
  • [Use MSYS2 instead](https://superuser.com/a/626712/241386) which only contains native Windows applications. Or use powershell which is far more powerful than cmd – phuclv Aug 29 '23 at 11:06

0 Answers0