How to kill a process in cygwin?

2019-03-14 07:53发布

Hi i have the following process which i cant kill:

The process to be killed.

I am running cygwin in windows xp 32 bit.

I have tried issuing the following commands:

/bin/kill -f 4760
/bin/kill -9 5000
kill -9 5000
kill 5000

When i write /bin/kill -f 4760 i get the message, 'kill: couldn't open pid 4760'.

When i write /bin/kill -9 5000 i get the message, 'kill: 5000: No such process'.

I simply don't understand why this process cant be killed. Since it has a WINID shouldnt it be killed by /bin/kill -f 4760?

hope someone can help thx :)

6条回答
何必那么认真
2楼-- · 2019-03-14 07:54

Different Windows programs will handle the signals that kill sends differently; they've never been designed to deal with them in the same way that Linux/Cygwin programs are.

The only reliable method for killing a Windows program is to use a Windows specific tool, such as Task Manager or Process Explorer.

That said, if you've not already, you may have luck with running your Cygwin terminal in administrator mode (right click on your shortcut and select "Run as administrator").

查看更多
一纸荒年 Trace。
3楼-- · 2019-03-14 07:55

The process is locked from Windows most likely. The error you are getting "couldnt open PID XXX" points to this. To confirm try killing it with windows taskkill

    taskkill /PID 4760
查看更多
干净又极端
4楼-- · 2019-03-14 08:08

killall.sh - Kill by process name.

#/bin/bash
ps -W | grep "$1" | awk '{print $1}' | xargs kill -f;

Usage:

$ killall <process name>
查看更多
对你真心纯属浪费
5楼-- · 2019-03-14 08:09

Create a file called killall.sh with this line

ps -W | grep $1 | awk '{print $1}' | while read line; do echo $line | xargs kill -f; done;

Then give it execute permissions.

chmod 777 killall.sh

In your .bash_profile add this line

alias killall="~/killall.sh"   (point it to the correct location)

Then you just have to type "killall [name]"

查看更多
成全新的幸福
6楼-- · 2019-03-14 08:09

The method presented by @Donal Tobin is correct:

kill -f <pid>

However, I don't need to log in as administrator.

查看更多
Melony?
7楼-- · 2019-03-14 08:14

Strangely, the following works in Cygwin:

echo PID1 PID2 PID3 | xargs kill -f

For example:

ps -W | grep WindowsPooPoo | awk '{print $1}' | while read line; do echo $line | xargs kill -f; done;
查看更多
登录 后发表回答