process kill prints
Browse files
app.py
CHANGED
@@ -185,12 +185,14 @@ def stop_process():
|
|
185 |
# check if pid_file exists, get the pid inside it and convert to int, and use os.kill to kill it
|
186 |
if os.path.isfile(pid_file):
|
187 |
with open(pid_file, 'r') as f: pid = int(f.read())
|
188 |
-
try:
|
|
|
|
|
189 |
except:
|
190 |
try:
|
191 |
process = subprocess.Popen(["taskkill", "/F", "/PID", str(pid)], stdout=subprocess.PIPE, stderr=subprocess.PIPE) # For Windows
|
192 |
process.communicate()
|
193 |
-
print("Process terminated successfully.")
|
194 |
except Exception as e:
|
195 |
print("Error:", e)
|
196 |
os.remove(pid_file)
|
|
|
185 |
# check if pid_file exists, get the pid inside it and convert to int, and use os.kill to kill it
|
186 |
if os.path.isfile(pid_file):
|
187 |
with open(pid_file, 'r') as f: pid = int(f.read())
|
188 |
+
try:
|
189 |
+
os.kill(pid, 9) # For linux
|
190 |
+
print("Process terminated successfully in Linux.")
|
191 |
except:
|
192 |
try:
|
193 |
process = subprocess.Popen(["taskkill", "/F", "/PID", str(pid)], stdout=subprocess.PIPE, stderr=subprocess.PIPE) # For Windows
|
194 |
process.communicate()
|
195 |
+
print("Process terminated successfully in Windows.")
|
196 |
except Exception as e:
|
197 |
print("Error:", e)
|
198 |
os.remove(pid_file)
|