Skip to content

Commit fa07efb

Browse files
authored
fixed it
it wasn't doing its job bc i tried to maintain some selfcrash functionality
1 parent 5b637a5 commit fa07efb

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

CF-Handler.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,23 @@
22
import time
33

44
def run_and_monitor():
5-
while True:
6-
try:
7-
# Start the child process
8-
print("Starting catflipper-linux...")
9-
process = subprocess.Popen(["./catflipper-linux"])
5+
try:
6+
# Start the child process
7+
print("Starting catflipper-linux...")
8+
process = subprocess.Popen(["./catflipper-linux"])
9+
process.wait()
1010

11-
# Wait for the process to finish
12-
process.wait()
11+
print("catflipper-linux crashed. Restarting...")
12+
time.sleep(2)
13+
run_and_monitor()
1314

14-
# If the process exits, log the exit code
15-
print(f"catflipper-linux exited with code {process.returncode}")
16-
17-
# Restart if the process was terminated or crashed
18-
if process.returncode != 0:
19-
print("catflipper-linux crashed. Restarting...")
20-
time.sleep(2) # optional: add delay before restart
21-
22-
except KeyboardInterrupt:
23-
print("Process monitor interrupted by user.")
24-
process.terminate() # ensure process cleanup on exit
25-
break
26-
except Exception as e:
27-
print(f"Error occurred: {e}")
28-
time.sleep(2) # optional: delay before attempting restart
15+
except KeyboardInterrupt:
16+
print("Process monitor interrupted by user.")
17+
process.terminate() # ensure process cleanup on exit
18+
except Exception as e:
19+
print(f"Error occurred: {e}")
20+
time.sleep(2)
21+
run_and_monitor()
2922

3023
if __name__ == "__main__":
3124
run_and_monitor()

0 commit comments

Comments
 (0)