pkill and pgrep certainly exist within Cygwin, in the procps package (you can search cygwin packages here).
It appears to work for me,
tony:~$ nohup sleep 100983 &
[1] 5476
tony:~$ nohup: ignoring input and appending output to `nohup.out'
tony:~$
tony:~$ ps -ef | grep sleep
tony 5476 2696 2 23:28:53 /usr/bin/sleep
tony:~$ pkill -f sleep
[1]+ Terminated nohup sleep 100983
tony:~$
and
tony:~$ nohup sleep 837746 &
[1] 228
tony:~$ nohup: ignoring input and appending output to `nohup.out'
tony:~$ pgrep -f 837746
228
tony:~$ pkill -f 837746
[1]+ Terminated nohup sleep 837746
tony:~$
Update: okay, tested with java. Executing java from the Cygwin command line does not result in the java string being placed into /proc/<pid>/cmdline
, that just contains -bash
.
This appears to be a limitation of Cygwin.
tony:~$ java -Dsomething=valid -jar Captor.jar &
[1] 2700
tony:~$ ps -ef
UID PID PPID TTY STIME COMMAND
tony 4164 1 ? Aug 21 /usr/bin/mintty
tony 4676 4164 0 Aug 21 /usr/bin/bash
tony 5776 4676 0 Aug 23 /usr/bin/ssh
tony 5148 1 ? 23:53:03 /usr/bin/mintty
tony 5332 5148 1 23:53:03 /usr/bin/bash
tony 5816 1 ? 00:04:16 /usr/bin/mintty
tony 5432 5816 2 00:04:16 /usr/bin/bash
tony 2700 5432 2 00:04:34 /cygdrive/c/Windows/system32/java
tony 2232 5432 2 00:04:39 /usr/bin/ps
tony:~$ pgrep -f something
tony:~$ cat /proc/2700/cmdline
-bash
tony:~$
tony:~$ cat /proc/2700/exename
/cygdrive/c/Windows/system32/java
I suspect therefore, the answer is you can't do this with a Cygwin tool, you would need a Windows specific tool.
killall
andpidof
crafted for Cygwin. Depends on Python 2/ - github.com/kata198/cygwin-ps-misc – Tim Savannah Nov 25 '14 at 16:28