File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -492,7 +492,20 @@ def get_filename_from_url(url):
492492 return os .path .basename (urlparse (url ).path .rstrip ("/" ))
493493
494494def kill_process (name ):
495- # Ask user for the name of process
495+ """
496+ Terminates all processes matching the given name.
497+
498+ Args:
499+ name (str): The name of the process to terminate.
500+
501+ Behavior:
502+ - Iterates through all processes to find those matching the given name.
503+ - Extracts the process ID (PID) and sends a SIGKILL signal to terminate it.
504+ - If an error occurs during termination, it prints an error message.
505+
506+ Note:
507+ This function uses the `ps` command to find processes and may not work on non-Unix systems.
508+ """
496509 import os , signal
497510 try :
498511 # iterating through each instance of the process
@@ -504,9 +517,8 @@ def kill_process(name):
504517
505518 # terminating process
506519 os .kill (int (pid ), signal .SIGKILL )
507- print ("Killing" ,pid )
508- except :
509- print ("Error Encountered while running script" )
520+ except Exception as e :
521+ print (f"Error Encountered while killing { name } " , e )
510522
511523def install_desktop_app_in_vm (
512524 debian_installer_url ,
You can’t perform that action at this time.
0 commit comments