So, I'm trying to make a program that, once closed, opens another window of itself, so it never stops unless shut down by task manager or unless the computer itself is shut down, of course. This is just to prank a friend, so no maliciousness. I want to to do this in Python, but if there are any other languages that can help me do this more efficiently, please let me know. I'm a beginning programming student, so I kinda need explanations/answers to be simple. Thanks in advance for your help!
Something like that is called a watchdog. If the target program dies, the watchdog restarts it. The only way you can stop the target program is to stop both the target and the watchdog.
For python you could try:
print("Watchdog start:") while True: # run forever print("Watchdog: process started") # program started message exec(open("./program.py").read()) # run the program print("Watchdog: process finished") # program stopped message print("Watchdog end:") # the watchdog is now finishing
import time for i in range (0, 5): print(i) time.sleep(1) print("I done")
For C/C++ you could look into forking/exec and poll the system for the process ID and just fork/exec it again if it dies.