educative.io

Unable to stop 4 CPU program in terminal

I ran the terminal where we have multiple cpu commands to execute but am unable to terminate them. They just keep running forever. Is it possible to terminate them ? Why or why not ?

(my intuition is that since we ran 4 of those commands, terminating in the shell 4 times should’ve been enough but that wasn’t the case)

1 Like

Hi @Jasmeher_Kathuria, Thanks for reaching out to us.

We really appreciate that you have shared your thoughts with us and explained them very well. It is great seeing that you guys are always coming up with betterments. We’ll look into it, Yes it is possible to terminate the process after running the 4 CPU command.

Please follow the steps below:

  1. Open a new terminal on the SPA widget.
  2. Find the Process IDs (PIDs): Use the ps command to find the PIDs of the running processes. Open a new terminal window and type:
    ps aux | grep cpu
  • You will see the PS ID in the second column as show in the screenshot (126,127,128…).
  1. Terminate Processes with kill: Use the kill command to terminate each process. Replace <PID> with the actual process ID.
kill 126
kill 127
kill 128
kill 129
  1. Go to the previous terminal. You will see the new iteration has stopped. Now press ctrl+c the process will terminate.

Please feel free to reply here if there is still some confusion.
Hope you have an amazing learning experience on Educative! :blush: