mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-21 16:05:02 +02:00
Better handling of failure to execute child
exec() a shell instead so that we are not left with a forked but not execed process
This commit is contained in:
@@ -2,13 +2,15 @@
|
|||||||
# vim:fileencoding=utf-8
|
# vim:fileencoding=utf-8
|
||||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
import os
|
|
||||||
import fcntl
|
import fcntl
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from .constants import terminfo_dir
|
|
||||||
import kitty.fast_data_types as fast_data_types
|
import kitty.fast_data_types as fast_data_types
|
||||||
|
|
||||||
|
from .constants import terminfo_dir
|
||||||
|
|
||||||
|
|
||||||
def remove_cloexec(fd):
|
def remove_cloexec(fd):
|
||||||
fcntl.fcntl(fd, fcntl.F_SETFD, fcntl.fcntl(fd, fcntl.F_GETFD) & ~fcntl.FD_CLOEXEC)
|
fcntl.fcntl(fd, fcntl.F_SETFD, fcntl.fcntl(fd, fcntl.F_GETFD) & ~fcntl.FD_CLOEXEC)
|
||||||
@@ -61,9 +63,13 @@ class Child:
|
|||||||
try:
|
try:
|
||||||
os.execvp(self.argv[0], self.argv)
|
os.execvp(self.argv[0], self.argv)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
# Report he failure and exec a shell instead so that
|
||||||
|
# we are not left with a forked but not execed process
|
||||||
print('Could not launch:', self.argv[0])
|
print('Could not launch:', self.argv[0])
|
||||||
print('\t', err)
|
print('\t', err)
|
||||||
input('\nPress Enter to exit:')
|
print('\nPress Enter to exit:', end=' ')
|
||||||
|
sys.stdout.flush()
|
||||||
|
os.execvp('/bin/sh', ['/bin/sh', '-c', 'read w'])
|
||||||
else: # master
|
else: # master
|
||||||
os.close(slave)
|
os.close(slave)
|
||||||
self.pid = pid
|
self.pid = pid
|
||||||
|
|||||||
Reference in New Issue
Block a user