Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a process running in cygwin and using a port. When I kill the process in another cygwin window by issuing command:

kill -9 PID   or  /bin/kill -f PID

I can see the process got terminated. However, the port is not released. Usually I can terminate the process cleanly by using ctrl-c. Is there a kill command that can have the same effect as ctrl-c in cygwin? Thanks!

share|improve this question
    
If the process is killed, the port will (eventually) time out and be freed –  mpez0 Sep 9 '10 at 19:07
    
It seems like the process is killed. Nothing shows up when I grep it. But I can see it in Windows Task Manager that the process is still running. In this case, the process is java.exe. If I end the process in Task Manager, the port is released instantly. –  logoin Sep 9 '10 at 19:17

2 Answers 2

Ctrl-C is a SIGINT I believe (signal interrupt), which would be equivalent to:

kill -2 PID

It's definitely lighter than a kill -9 as it will give the process some time to clean up after itself.

For more info see man kill.

share|improve this answer
    
I tried this command. It looks like the process is terminated but the port is still in used. Is there a way to make sure the port is released when the process is killed? Thanks! –  logoin Sep 9 '10 at 18:34
    
Cygwin can still run batch scripts, you know :) Make your own kill implementation and add it to your path. In the script you can use something as simple as taskkill /T /PID %1 @logoin –  John T Sep 9 '10 at 22:07

kill -9 should only be used as a last resort. If kill -SIGNINT PID isn't doing what you want, try kill -SIGTERM PID. These signals can be trapped by the application and it can do what it wants with them including performing cleanup or ignoring them.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.