Jan-04-2018, 06:25 PM
(This post was last modified: Jan-04-2018, 06:25 PM by Gribouillis.)
You have launched a fork bomb. You'd better shutdown and reboot. It's not the three lines you just posted that open and close many terminals. Can you post the real code?
Here is a full code that works for me in linux, but the terminal application is
The
the code. An alternative is to add a command that waits at the end, such as
Here is a full code that works for me in linux, but the terminal application is
konsole
, which has its own optionsimport argparse import subprocess import sys def main_work(args): print('Hello from term-example') def main(): parser = argparse.ArgumentParser() parser.add_argument( '--noterminal', help="don't start a new terminal'", action='store_true') ns = parser.parse_args() try: sys.stdout.fileno() except Exception: # not a terminal for sure if ns.noterminal: raise RuntimeError('Need a terminal to run.') else: subprocess.call(['konsole', '--noclose', '-e', sys.executable, __file__, '--noterminal']) else: main_work(ns) if __name__ == '__main__': main()When I run this code in a terminal, it simply executes the code in
main_work()
. When I run it from IDLE3 by pressing the F5 key, it launches a new console and executes the code from main_work()
in this console.The
konsole
command has an option --noclose
so that it stays here after the execution ofthe code. An alternative is to add a command that waits at the end, such as
if ns.noterminal: input()