Why can't kill the process with taskkill? - windows-7

how to kill the process
>netstat -nao
Active Connections
Proto Local Address Foreign Address State PID
TCP 10.10.8.10:50931 122.109.119.13:22 ESTABLISHED 4664
>taskkill /pid 4664
SUCCESS: Sent termination signal to the process with PID 4664.
>netstat -nao
Active Connections
Proto Local Address Foreign Address State PID
TCP 10.10.8.10:50931 122.109.119.13:22 ESTABLISHED 4664
why i can not kill pid 4664 with taskkill /pid 4664

Try passing the following parameters to TASKKILL:
/T = kill child process
/F = forceful termination
Another option would be to use Power Shell to kill by pid:
kill -id 4664
If nothing works, maybe the process is blocked waiting for some resource (perhaps a bug). Consider rebooting.

Sorry if this is too elementary, but you may want to
try looking under some of your open windows for a system message..
Ie "do you want to save"
Windows might be being polite and not closing the app before giving you a chance to save or don't save.
it also may be on the screen of the remote computer.

Related

VS Code: Starting inspector on 127.0.0.1:9229 failed: address already in use

So far, I have used "processId": {command: PickProcess} ", maybe it's not the best method, but it always worked." Unfortunately, this method has not worked for a few days. (Please see attachment)
In the console I get "Starting inspector on 127.0.0.1:9229 failed: address already in use".
I have not figured out what the problem is. Can someone give me a hint?
I was facing the same issue on my linux machine.
Ran lsof -i :9229 command to find which process is using port 9229
Then ran kill -9 <process id using the port>
Its usually extension manager, then restart
Alternatively, you can open process manager in vs code and kill extension host
Then restart vscode and try to debug by using attach to process id
For windows:
C:\Users\Niroshan>netstat -ano|findstr "PID :8080"
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 18264
taskkill /pid 18264 /f
as mentioned in this answer:

Windows Kill Process By PORT Number [duplicate]

This question already has answers here:
How do I kill the process currently using a port on localhost in Windows? [closed]
(28 answers)
Closed 3 years ago.
I'm using embedded Tomcat server in Spring Tool Suite IDE. My problem is when I run my project there is an error as follows,
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.
There are some similar questions but none of the answers not working for me.
Solution 1: Kill Process
Run command-line as an Administrator
netstat -ano | findstr :<yourPortNumber>
taskkill /PID <typeyourPIDhere> /F
Solution 2: Change Port
Please Make sure that new port you are going to set for your Application doesn't listen to any other process
Change the port
server.port=8088 # Server HTTP port.
Solution 3:
Another way is to terminate the process (in IDE) and clean and rebuild project.
UPDATE:
For solution 2, Please Make sure that new port you are going to set for your Application doesn't listen to any other process.
How to check Port Status?
Option 1
Run resmon.exe and go to Network -> Listening Port (Also can be viewed on TaskManager)
Option 2
PowerShell
Get-Process -Id (Get-NetTCPConnection -LocalPort portNumber).OwningProcess
cmd
C:\> netstat -a -b
(Add -n to stop it trying to resolve hostnames, which will make it a lot faster.)
-a Displays all connections and listening ports.
-b Displays the executable involved in creating each connection or listening port. In some cases, well-known executables host multiple independent components, and in these cases, the sequence of components involved in creating the connection or listening port is displayed. In this case, the executable name is in [] at the bottom, on top is the component it called, and so forth until TCP/IP was reached. Note that this option can be time-consuming and will fail unless you have sufficient permissions.
-n Displays addresses and port numbers in numerical form.
-o Displays the owning process ID associated with each connection.
I found that the answer by PatelRomil didn't work for me. I found that by running:
netstat -a -o -n
And getting the PID for the port, and then running:
taskkill /F /PID [PID]
Worked for me. Replace [PID] with the value in the table from the previous command.

Gracefully terminate a command line application on Windows

I'm creating a command-line application, which spawns a process (command defined by a user, usually an HTTP server) and when the application's job is done, I want to let the process know it should terminate.
In UNIX, I can do that by sending SIGTERM and if the process doesn't end, then I can kill it brutally by SIGKILL.
In Windows, I struggle to find an alternative to the SIGTERM scenario. I learned there's taskkill /PID XXXX (without /f!), but
I found no information about what taskkill /PID XXXX does under the hood, hence I can't test it. I can't find how to handle whatever taskkill /PID XXXX sends on the process side.
It doesn't seem to work with commands in cmd.exe. I tried to run a simple server process in one cmd.exe, get its PID and in another window to taskkill /PID XXXX it, but taskkill refused to do that: ERROR: The process with PID XXXX could not be terminated. Reason: This process can only be terminated forcefully (with /F option).
So my question is: How to inform a command-line process in Windows that it should terminate without forcefully terminating it? How to receive and act upon such message on the process-to-be-terminated side?
GenerateConsoleCtrlEvent signals a console application as if the user had pressed Ctrl+C or Ctrl+Break. Console applications can ignore these signals (using SetContolCtrlHandler), but, by default, they just do an ExitProcess on themselves.
This is the same signal Windows uses when the user closes the console window, logs off, or shuts down.
TaskKill uses PostMessage(hwnd, WM_CLOSE, 0, 0); (basically the same as pressing the X on a window) if the process has a visible window.
If you know the application is a console application you can use GenerateConsoleCtrlEvent instead.

Kill a process using a port (Windows/C)

How can I kill (or just find the pid. The killing is easy) of a process that is listening on a certain port from c/c++ on Windows?

How to kill an open process on node.js?

I'm trying to set up a build-system for Node.js on sublime, so I can press F7 to call "node" on the openned file. The problem is that the process is then open forever, so, the second time I use F7 I get an add-in-use.
Is there a way I can kill the openned "node.exe" process from node.js?
Use the following set of commands to identify the process running on a given port and to termiate it from the command line
sudo fuser -v 5000/tcp // gives you the process running on port 5000
It will output details similar to the one shown below
USER PID ACCESS COMMAND
5000/tcp: almypal 20834 F.... node
Then use
sudo fuser -vk 5000/tcp
to terminate the process. Check once again using
sudo fuser -v 5000/tcp
to ensure that the process has terminated.
On Windows you could use the following steps
C:\> tasklist // will show the list of running process'
Image Name PID Session Name Session# Mem Usage
System 4 console 0 236 K
...
node.exe 3592 console 0 8440 k
Note the PID corresponding to your node process, in this case 3592. Next run taskkill to terminate the process.
C:\> taskkill /F /PID 3592
Or /IM switch
C:\> taskkill /F /IM node.exe
From within Node.js:
var die = function(quitMsg)
{
console.error(quitMsg)
process.exit(1);
}
die('Process quit');
There are certain methods available for exiting that are only available for POSIX (i.e. not Windows) that will exit a process by its process id.
Also, note that you might be able to send a kill() signal using this method, which does not say it isn't available for Windows:
process.kill(pid, [signal])
If you want to kill all processes than:
sudo killall -9 node
If you want to kill process on selected port than:
sudo kill sudo lsof -t -i:3100
That was port 3100
If sublime you say is sublimeText plugin, I have the same issue, and send TCP server a message 'shutdown' from python code, then
app.js
TCPserver
.on('connection', function(socket)
{
socket.pipe(require('through')
(function(data)
{ //----------------------------
if (data.toString() === 'shutdown')
{
process.exit();
}
//--------------------------
}));
socket.end();
})
Similarly to what #Alex W said, you can send a kill signal to the process so long as you have its process ID, or PID using the following node function:
process.kill(pid, [signal])
In my case, I had the PIDs readily available as I was spawning child_process().spawn.pid. I have tested it and it does work on Win 7 x64.

Resources