-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·53 lines (43 loc) · 1.13 KB
/
main.py
File metadata and controls
executable file
·53 lines (43 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
"""
Codestral CLI - Entry Point with BULLETPROOF Exit Handling
"""
import sys
import signal
import os
import atexit
def force_exit():
"""Force exit immediately - no exceptions"""
try:
os._exit(0)
except:
try:
sys.exit(0)
except:
exit(0)
def setup_bulletproof_exit():
"""Setup absolutely bulletproof exit handlers"""
def bulletproof_handler(signum, frame):
print(f"\n🛑 BULLETPROOF EXIT (Signal {signum})")
force_exit()
# Handle ALL possible interrupt signals
signals = [signal.SIGINT, signal.SIGTERM]
try:
signals.extend([signal.SIGQUIT, signal.SIGHUP])
except AttributeError:
pass
for sig in signals:
try:
signal.signal(sig, bulletproof_handler)
except (OSError, ValueError):
pass
# Register cleanup function
atexit.register(force_exit)
if __name__ == "__main__":
# Setup bulletproof exit FIRST
setup_bulletproof_exit()
try:
from codestral_cli.core.cli import main
main()
except:
force_exit()