Skip to content

Commit 1567573

Browse files
committed
fixup! add an option to skip draining on tty close
1 parent 1a71df5 commit 1567573

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

main.c

+1
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ int main(int argc, char *argv[], char *envp[])
789789
{
790790
opts.tty = 1;
791791
opts.ttyopts.ptmx = tty_default_ptmx;
792+
opts.ttyopts.drain = true;
792793

793794
/* 128 is enough to support everything */
794795
struct kvlist kvlist[128];

man/bst.1.scd

+3
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ spacetime process.
371371
- *ptmx*=<path>: use the specified ptmx device (relative to the target root)
372372
to allocated the pty.
373373

374+
- *drain*: whether to drain the tty on stdin closure. The default is true,
375+
so prepend a _'-'_ to this option to prevent draining.
376+
374377
By default bst inherits the parent's terminal device (or lack thereof). Use
375378
the --tty option to allocate a new pty for the child process.
376379

tty.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,7 @@ void tty_parent_setup(struct tty_opts *opts, int epollfd, int socket)
362362

363363
struct termios tios;
364364

365-
if (opts->drain != NULL) {
366-
info.drain = *opts->drain;
367-
}
365+
info.drain = opts->drain;
368366

369367
info.stdinIsatty = tcgetattr(STDIN_FILENO, &tios) == 0;
370368
if (!info.stdinIsatty && errno != ENOTTY) {
@@ -669,8 +667,7 @@ static void parse_drain(struct tty_opts *opts, const char *key, const char *val,
669667
if (val != NULL) {
670668
errx(2, "tty option '%s' must have no value", key);
671669
}
672-
opts->drain = malloc(sizeof(bool));
673-
*opts->drain = (key[0] != '-');
670+
opts->drain = (key[0] != '-');
674671
}
675672

676673
static int cmp_flag(const void *key, const void *elem)

tty.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct tty_opts {
1515
const char *ptmx;
1616
struct termios termios;
1717
struct termios neg_termios;
18-
bool *drain;
18+
bool drain;
1919
};
2020

2121
extern const char *tty_default_ptmx;

0 commit comments

Comments
 (0)