Ask coding questions

← Back to all posts
How to kill a running process ?
gotcha1 (2)

I have started a Plone server via the repl.it shell.
I have closed the repl.it page with the server still running: http://ploneinrepl--gotcha1.repl.co
If I open the repl again and open the shell, how can I kill the running process ?

Comments
hotnewtop
Masy (35)

In Repl, its a little hard to kill a process, in a linux machine i think its ctrl-c

TheDrone7 (1901)

You won't be able to kill the process from the shell. The two easiest ways to do it are:-
1. Wait for 1 hour for it to kill itself.
2. Write 1 or 2 words deliberately to make the code buggy, then restart.

gotcha1 (2)

@TheDrone7 Thanks for your answer.
Trying 2, I have saved broken code for main.py and clicked the green start button.
This nicely fails in the python interpreter but does not kill the server started via the shell.

TheDrone7 (1901)

@gotcha1 if you've started it via shell Ctrl + C to kill it.

gotcha1 (2)

@TheDrone7 which I could do if I did not have quit the repl opened in browser.
When I get back to my repl, I get a new shell without access to the running process... or at least, I do not know how to get access to it.
Which is why I ask how to kill it.

TheDrone7 (1901)

@gotcha1 the only way I can think of now is to fork the repl and use the new one after deleting the old one.

PythinPython (10)

@gotcha1 If I am understanding you correctly then I believe there is no efficient way to kill it. But if you wait for a while the program will stop responding and in a way kill itself (like what TheDrone7 said).

Vandesm14 (2737)

@PythinPython Can't you do top in the shell, get the pid of the process, and type kill [pid]?

gotcha1 (2)

@Vandesm14 I had not thought of top. However, neither top, neither ps commands are available in the shell.

TheDrone7 (1901)

@Vandesm14 that would require superuser permissions and repl.it doesn't give you that.

TheDrone7 (1901)

@PythinPython the repl won't go down on it's own either if started using the shell, unlike the normal repls, it stays up for a little longer than normally started ones. So the quicker way would be to fork it and continue working in the new one.

gotcha1 (2)

@TheDrone7 I have forked the repl as suggested.
For the record, if I run Plone in daemon mode and I write down its pid, I am able/allowed to kill it.

TheDrone7 (1901)

@gotcha1 well that's good news. Last time I tried kill didn't go well for me.

alejo4373 (0)

It looks like you can use the pidof command to identify the process id and then the kill command to stop it. I had an Express (Node.js) server that I couldn't kill and in the console I kept seeing the error EADDRINUSE (the port was already in use) due to Repl.it running my code automatically.

So pidof node and then kill <pid> worked for me. Note that in my case there were multiple pids for node so I used the piped commands below to kill all node processes

pidof node | awk 'BEGIN { RS = " " } { print $1}' | while read line ; do kill $line ; done