Flush the write to shm explicitly
This commit is contained in:
parent
4013544efb
commit
f67009f554
@ -129,7 +129,7 @@ def make_tarfile(ssh_opts: SSHOptions, base_env: Dict[str, str], compression: st
|
|||||||
if ksi:
|
if ksi:
|
||||||
arcname = 'home/' + rd + '/shell-integration'
|
arcname = 'home/' + rd + '/shell-integration'
|
||||||
tf.add(shell_integration_dir, arcname=arcname, filter=filter_from_globs(
|
tf.add(shell_integration_dir, arcname=arcname, filter=filter_from_globs(
|
||||||
f'{arcname}/ssh/bootstrap.*', # bootstrap files are sent as command line args
|
f'{arcname}/ssh/*', # bootstrap files are sent as command line args
|
||||||
f'{arcname}/zsh/kitty.zsh', # present for legacy compat not needed by ssh kitten
|
f'{arcname}/zsh/kitty.zsh', # present for legacy compat not needed by ssh kitten
|
||||||
))
|
))
|
||||||
tf.add(terminfo_dir, arcname='home/.terminfo', filter=normalize_tarinfo)
|
tf.add(terminfo_dir, arcname='home/.terminfo', filter=normalize_tarinfo)
|
||||||
@ -234,6 +234,7 @@ def bootstrap_script(
|
|||||||
with SharedMemory(size=len(db) + len(sz), mode=stat.S_IREAD, prefix=f'kssh-{os.getpid()}-') as shm:
|
with SharedMemory(size=len(db) + len(sz), mode=stat.S_IREAD, prefix=f'kssh-{os.getpid()}-') as shm:
|
||||||
shm.write(sz)
|
shm.write(sz)
|
||||||
shm.write(db)
|
shm.write(db)
|
||||||
|
shm.flush()
|
||||||
atexit.register(shm.unlink)
|
atexit.register(shm.unlink)
|
||||||
replacements = {
|
replacements = {
|
||||||
'DATA_PASSWORD': pw, 'PASSWORD_FILENAME': shm.name, 'EXEC_CMD': exec_cmd, 'TEST_SCRIPT': test_script,
|
'DATA_PASSWORD': pw, 'PASSWORD_FILENAME': shm.name, 'EXEC_CMD': exec_cmd, 'TEST_SCRIPT': test_script,
|
||||||
|
|||||||
@ -46,8 +46,9 @@ class SharedMemory:
|
|||||||
def __init__(
|
def __init__(
|
||||||
self, name: str = '', size: int = 0, readonly: bool = False,
|
self, name: str = '', size: int = 0, readonly: bool = False,
|
||||||
mode: int = stat.S_IREAD | stat.S_IWRITE,
|
mode: int = stat.S_IREAD | stat.S_IWRITE,
|
||||||
prefix: str = 'kitty-'
|
prefix: str = 'kitty-', unlink_on_exit: bool = False
|
||||||
):
|
):
|
||||||
|
self.unlink_on_exit = unlink_on_exit
|
||||||
if size < 0:
|
if size < 0:
|
||||||
raise TypeError("'size' must be a non-negative integer")
|
raise TypeError("'size' must be a non-negative integer")
|
||||||
if size and name:
|
if size and name:
|
||||||
@ -100,6 +101,9 @@ class SharedMemory:
|
|||||||
def seek(self, pos: int, whence: int = os.SEEK_SET) -> None:
|
def seek(self, pos: int, whence: int = os.SEEK_SET) -> None:
|
||||||
self.mmap.seek(pos, whence)
|
self.mmap.seek(pos, whence)
|
||||||
|
|
||||||
|
def flush(self) -> None:
|
||||||
|
self.mmap.flush()
|
||||||
|
|
||||||
def __del__(self) -> None:
|
def __del__(self) -> None:
|
||||||
try:
|
try:
|
||||||
self.close()
|
self.close()
|
||||||
@ -111,6 +115,8 @@ class SharedMemory:
|
|||||||
|
|
||||||
def __exit__(self, *a: object) -> None:
|
def __exit__(self, *a: object) -> None:
|
||||||
self.close()
|
self.close()
|
||||||
|
if self.unlink_on_exit:
|
||||||
|
self.unlink()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def size(self) -> int:
|
def size(self) -> int:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user