Skip to content

Commit 70e068e

Browse files
committed
Fix forward_stdio not working on macOS
1 parent cea9258 commit 70e068e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

kitty/child.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,14 @@ def fork(self) -> Optional[int]:
319319
if ksi == 'invalid':
320320
ksi = 'enabled'
321321
argv = [kitten_exe(), 'run-shell', '--shell', shlex.join(argv), '--shell-integration', ksi]
322-
if is_macos:
322+
if is_macos and not self.pass_fds and not opts.forward_stdio:
323323
# In addition for getlogin() to work we need to run the shell
324324
# via the /usr/bin/login wrapper, sigh.
325325
# And login on macOS looks for .hushlogin in CWD instead of
326326
# HOME, bloody idiotic so we cant cwd when running it.
327327
# https://github.com/kovidgoyal/kitty/issues/6511
328+
# login closes inherited file descriptors so dont use it when
329+
# forward_stdio or pass_fds are used.
328330
import pwd
329331
user = pwd.getpwuid(os.geteuid()).pw_name
330332
if cwd:

kitty/options/definition.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3316,7 +3316,9 @@
33163316
allows child processes to print to kitty's STDOUT directly. For example,
33173317
:code:`echo hello world >&$KITTY_STDIO_FORWARDED` in a shell will print
33183318
to the parent kitty's STDOUT. Sets the :code:`KITTY_STDIO_FORWARDED=fdnum`
3319-
environment variable so child processes know about the forwarding.
3319+
environment variable so child processes know about the forwarding. Note that
3320+
on macOS this prevents the shell from being run via the login utility so getlogin()
3321+
will not work in programs run in this session.
33203322
''')
33213323

33223324
opt('+menu_map', '',

0 commit comments

Comments
 (0)