Skip to content
Advertisement

Kill program listening to a given port

Before the main code execution starts, I want to check if a particular port is open or not.. and if it is.. then close the port so that code can start “cleanly”.

So I google online and found the code here: http://www.paulwhippconsulting.com.au/tips/63-finding-and-killing-processes-on-ports

But just pasting the code from there:

JavaScript

But it throws an error.

JavaScript

Advertisement

Answer

The fellow who posted that snippet forgot to HTML-escape his code! The correct code is as follows:

JavaScript

Note that <pid> follows the ?P.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement