diff --git a/fs/pty.c b/fs/pty.c index 1b272296cf..0ecd0cd295 100644 --- a/fs/pty.c +++ b/fs/pty.c @@ -66,6 +66,12 @@ static int pty_slave_open(struct tty *tty) { return _EIO; if (tty->pty.locked) return _EIO; + // If userland's reference count on the pty slave is now 1, clear + // hang_up on the pty master. But the session leader may have a + // reference, and the pty master always has a reference. + if (tty->refcount - 1 == (tty->session ? 2 : 1)) { + tty->pty.other->hung_up = false; + } return 0; } diff --git a/fs/tty.c b/fs/tty.c index 3a70ca2943..a9a950531e 100644 --- a/fs/tty.c +++ b/fs/tty.c @@ -446,6 +446,7 @@ static ssize_t tty_read(struct fd *fd, void *buf, size_t bufsize) { lock(&tty->lock); if (tty->hung_up || pty_is_half_closed_master(tty)) { unlock(&pids_lock); + err = -1; goto error; } diff --git a/meson.build b/meson.build index 4a8ea6df48..eb273920ba 100644 --- a/meson.build +++ b/meson.build @@ -181,8 +181,8 @@ endif subdir('tools') -gdb_scripts = ['ish-gdb.gdb'] -foreach script : gdb_scripts +debugger_scripts = ['ish-gdb.gdb', 'ish-lldb.lldb'] +foreach script : debugger_scripts custom_target(script, output: script, input: script, command: ['ln', '-sf', '@INPUT@', '@OUTPUT@'],