added socket close when exiting. added pkill to users pid to clear /dev/shm. added exit post program to kill with pkill again due to atexit handler not responding to signals from outside python

This commit is contained in:
jenz 2024-01-06 19:38:47 +01:00
parent 5005985ce3
commit 6d91f50133
2 changed files with 15 additions and 4 deletions

View File

@ -0,0 +1,9 @@
#!/home/autismbot1/ze_runner/venv/bin/python3
if __name__ == '__main__':
import subprocess
#deleting POSIX shared memory objects, as long as one process has them open they exist. THis is to prevent /dev/shm from being full
#due to steam child processes.
#even with steam turned offline might there be chromium web browsers left over from steam who still hold processes open.
#only kind of potential issues from this is steam cloud being out of sync, which is really fucking irrelevant.
subprocess.getoutput([f"pkill -9 -u {whoami}"])

View File

@ -35,6 +35,11 @@ def exit_handler():
#securing the looptest.cfg wont be stuck accidently with commands
kill_owned_process("pidof hl2_linux")
kill_owned_process("pidof xterm")
#deleting POSIX shared memory objects, as long as one process has them open they exist. THis is to prevent /dev/shm from being full
#due to steam child processes.
#even with steam turned offline might there be chromium web browsers left over from steam who still hold processes open.
#only kind of potential issues from this is steam cloud being out of sync, which is really fucking irrelevant.
subprocess.getoutput([f"pkill -9 -u {whoami}"])
def bot_process_movement(input_line):
dist_target = input_line[input_line.index("dist_target:") + len("dist_target:"):input_line.index("enemy_distance")]
@ -178,10 +183,6 @@ if __name__ == '__main__':
if maps_folder_size > 40.0:
for f in glob.glob(f"/home/{whoami}/.steam/debian-installation/steamapps/common/Counter-Strike Source/cstrike/download/maps/*"):
subprocess.Popen(["rm", f], stdout=subprocess.PIPE).communicate()[0]
#deleting POSIX shared memory objects, as long as one process has them open they exist. so probably until steam gets turned off. THis is to prevent /dev/shm from being full
#subprocess.getoutput([f"rm /dev/shm/u1001-Shm_*"])
#subprocess.getoutput([f"rm /dev/shm/u1002-Shm_*"])
#NOTE since not running vm's anymore i quit doing this. instead just restarting the service every 10 hours.
restart_sdl_and_steam()
is_bot_connected_to_ze2 = False
@ -233,6 +234,7 @@ if __name__ == '__main__':
if connection_issue_counter == 5:
kill_owned_process("pidof hl2_linux")
print('exiting')
sock.close()
sys.exit(1)
else:
if call_bot_connect: