Kitty: How to exit when main process ended leaving subprocess

Created on 4 Feb 2018  路  5Comments  路  Source: kovidgoyal/kitty

Hello! Thanks for Kitty!

In xterm (and most terminals), if you run ( inkscape & ); exit, it will close the terminal leaving inkscape open. But in kitty, it will open inkscape and wait it to finish before closing the terminal. Is there a way to configure this behavior?

Most helpful comment

All you need to do is redirect stdin/stdout/stderr

subprocess.Popen('inkscape', stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL)

All 5 comments

No there is no such option, and I dont really see the point. Closing the terminal automatically while there is still some process connected to it is just bad behavior. If you want to close the terminal at any time simple press ctrl+shift+w

So instead of typing: inkscape & exit

Type: inkscape &

Or if you want to do it via a command use:

nohup inkscape & disown; exit

Oh and just for completeness, before somebody complains that using nohup means typing a lot, you can define the following in your zshrc/bashrc

function launch {
    nohup $1 >/dev/null 2>/dev/null & disown; exit
}

Then just type

launch inkscape

in the terminal to run inkscape and close the terminal at once.

Thanks for the quick reply @kovidgoyal !

I need this for a python script, that's why I can't use hotkeys to close the window.
The command you said seems to work well when using it manually on the terminal, maybe I can also use it with python, like this subprocess.run('nohup %s & disown; exit' % cmd, shell=True). Would you have a better idea about how to do it on python? Thanks for the help!
(I tried using os.fork(), but the terminal stays open waiting the child.)

All you need to do is redirect stdin/stdout/stderr

subprocess.Popen('inkscape', stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL)

Oh, it works! Thanks!
And sorry for unintentionally misguiding you with the first message. I thought it would be easier to talk here about shell language.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hdriqi picture hdriqi  路  3Comments

skosch picture skosch  路  3Comments

Askannz picture Askannz  路  3Comments

JJGO picture JJGO  路  3Comments

atomsymbol picture atomsymbol  路  3Comments