Skip to content

Instantly share code, notes, and snippets.

Last active Oct 8, 2020
What would you like to do?
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Made by papi
# Created on: Mon 07 Sep 2020 06:50:04 PM CEST
# Description:
import socket, signal
import sys, os, time
import time
from threading import *
def empty_king_file():
open(KING_FILE, 'w').close()
# Check if the king file is different than the name
# on success return the file descriptor, on error returns None
def check_file():
fpr = open(KING_FILE, 'r', encoding='utf-8')
val =
if val != USER_NAME:
fpw = open(KING_FILE, 'w', encoding='utf-8')
empty_king_file() # Empty the file before being able to add name
return fpw
return None
# function that changes the king file
def change_file():
file = check_file()
if file != None:
file.write(USER_NAME + '\n') # Need a \n to be appended to act like
file.close() # an echo
if __name__ == "__main__":
if len(sys.argv) == 2:
os.kill(int(sys.argv[1]), signal.SIGINT)
os.system("python3 " + sys.argv[0] + " " + str(os.getpid()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment