Retrieve child exit status before shutting down
This commit is contained in:
parent
51e5ed9599
commit
a045f4f0e6
@ -13,7 +13,7 @@ from gettext import gettext as _
|
|||||||
from .config import load_config
|
from .config import load_config
|
||||||
from .constants import appname, str_version, config_dir
|
from .constants import appname, str_version, config_dir
|
||||||
from .boss import Boss
|
from .boss import Boss
|
||||||
from .utils import fork_child, hangup
|
from .utils import fork_child, hangup, get_child_status
|
||||||
from .shaders import GL_VERSION
|
from .shaders import GL_VERSION
|
||||||
from .fast_data_types import glewInit, enable_automatic_opengl_error_checking
|
from .fast_data_types import glewInit, enable_automatic_opengl_error_checking
|
||||||
import glfw
|
import glfw
|
||||||
@ -56,7 +56,9 @@ def run_app(opts, args):
|
|||||||
glfw.glfwMakeContextCurrent(window)
|
glfw.glfwMakeContextCurrent(window)
|
||||||
glewInit()
|
glewInit()
|
||||||
glfw.glfwSwapInterval(1)
|
glfw.glfwSwapInterval(1)
|
||||||
|
child = args.args or [pwd.getpwuid(os.geteuid()).pw_shell or '/bin/sh']
|
||||||
boss = Boss(window, window_width, window_height, opts, args)
|
boss = Boss(window, window_width, window_height, opts, args)
|
||||||
|
fork_child(child, args.directory, opts)
|
||||||
glfw.glfwSetFramebufferSizeCallback(window, boss.on_window_resize)
|
glfw.glfwSetFramebufferSizeCallback(window, boss.on_window_resize)
|
||||||
boss.start()
|
boss.start()
|
||||||
try:
|
try:
|
||||||
@ -69,6 +71,7 @@ def run_app(opts, args):
|
|||||||
boss.close()
|
boss.close()
|
||||||
boss.join()
|
boss.join()
|
||||||
boss.destroy()
|
boss.destroy()
|
||||||
|
get_child_status() # Ensure child does not become zombie
|
||||||
finally:
|
finally:
|
||||||
glfw.glfwDestroyWindow(window)
|
glfw.glfwDestroyWindow(window)
|
||||||
|
|
||||||
@ -93,8 +96,6 @@ def main():
|
|||||||
if not glfw.glfwInit():
|
if not glfw.glfwInit():
|
||||||
raise SystemExit('GLFW initialization failed')
|
raise SystemExit('GLFW initialization failed')
|
||||||
try:
|
try:
|
||||||
child = args.args or [pwd.getpwuid(os.geteuid()).pw_shell or '/bin/sh']
|
|
||||||
fork_child(child, args.directory, opts)
|
|
||||||
if args.profile:
|
if args.profile:
|
||||||
tf = tempfile.NamedTemporaryFile(prefix='kitty-profiling-stats-')
|
tf = tempfile.NamedTemporaryFile(prefix='kitty-profiling-stats-')
|
||||||
args.profile = tf.name
|
args.profile = tf.name
|
||||||
|
|||||||
@ -84,10 +84,21 @@ def hangup():
|
|||||||
if hasattr(fork_child, 'pid'):
|
if hasattr(fork_child, 'pid'):
|
||||||
pid = fork_child.pid
|
pid = fork_child.pid
|
||||||
del fork_child.pid
|
del fork_child.pid
|
||||||
pgrp = os.getpgid(pid)
|
try:
|
||||||
|
pgrp = os.getpgid(pid)
|
||||||
|
except ProcessLookupError:
|
||||||
|
return
|
||||||
os.killpg(pgrp, signal.SIGHUP)
|
os.killpg(pgrp, signal.SIGHUP)
|
||||||
os.close(create_pty()[0])
|
os.close(create_pty()[0])
|
||||||
|
|
||||||
|
|
||||||
|
def get_child_status():
|
||||||
|
if hasattr(fork_child, 'pid'):
|
||||||
|
try:
|
||||||
|
return os.waitid(os.P_PID, fork_child.pid, os.WEXITED | os.WNOHANG)
|
||||||
|
except ChildProcessError:
|
||||||
|
del fork_child.pid
|
||||||
|
|
||||||
base_size = sys.getsizeof('')
|
base_size = sys.getsizeof('')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user