Search code examples
bashcygwin

How do i get the Windows PPID of a procces running out of cygwin?


I need to kill a windows procces that were started by the programm called from cygwin.

Here's what I do:

${wccoaDirNix}/bin/WCCILpmon.exe -proj ${projName} -user root: &

This process creates other windows process:

$ ps -W
      PID    PPID    PGID     WINPID   TTY         UID    STIME COMMAND
     1960       1    1960       1960  ?         197609 19:21:57 /usr/bin/mintty
     7316       0       0       7316  ?              0 19:21:57 C:\Windows\System32\conhost.exe
     1700    1960    1700       1576  pty1      197609 19:21:57 /usr/bin/bash
I   10760    9840   10760       7560  pty0      197609 19:25:47 /usr/bin/bash
       32   10760   10760         32  pty0      197609 19:26:28 /cygdrive/c/Siemens/Automation/WinCC_OA/3.14/bin/WCCILpmon
     6264       0       0       6264  ?              0 19:26:28 C:\Siemens\Automation\WinCC_OA\3.14\bin\WCCILpmon.exe
     8420       0       0       8420  ?              0 19:26:29 C:\Siemens\Automation\WinCC_OA\3.14\bin\WCCILdata.exe
     6336       0       0       6336  ?              0 19:26:29 C:\Windows\System32\conhost.exe
     2808       0       0       2808  ?              0 19:26:30 C:\Siemens\Automation\WinCC_OA\3.14\bin\WCCILevent.exe
     6784       0       0       6784  ?              0 19:26:30 C:\Windows\System32\conhost.exe
     2972       0       0       2972  ?              0 19:26:30 C:\Siemens\Automation\WinCC_OA\3.14\bin\WCCOActrl.exe
    11004       0       0      11004  ?              0 19:26:30 C:\Windows\System32\conhost.exe
     9536       0       0       9536  ?              0 19:26:31 C:\Siemens\Automation\WinCC_OA\3.14\bin\WCCILsim.exe
     7372       0       0       7372  ?              0 19:26:31 C:\Windows\System32\conhost.exe
     9128       0       0       9128  ?              0 19:26:31 C:\Siemens\Automation\WinCC_OA\3.14\bin\WCCOAui.exe
     3964       0       0       3964  ?              0 19:27:48 C:\Siemens\Automation\WinCC_OA\3.14\bin\WCCILdatabg.exe

How can i kill them?

I tried to kill them by the following command:

ps -W | grep "WCC" | awk '{print $1}' | xargs kill -f;

But it does not work as it should, it kills all processes in which name there are letters WCС, and I need to terminate only the child processes of WCCILpmon.exe

I also read the question on cygwinlist about same problem

And it upset me, is there no way to realize it?


Solution

  • As you need to kill a NOT cygwin process, it is better to use windows specific program.

    One example is:

    https://learn.microsoft.com/en-us/sysinternals/downloads/pskill