Skip to content

Comments

Rework waitForInput. [VDO-5574]#19

Merged
raeburn merged 1 commit intodm-vdo:mainfrom
raeburn:waitForInput
Jan 30, 2026
Merged

Rework waitForInput. [VDO-5574]#19
raeburn merged 1 commit intodm-vdo:mainfrom
raeburn:waitForInput

Conversation

@raeburn
Copy link
Member

@raeburn raeburn commented Jan 22, 2026

Our tests use subprocesses created by Proc::Simple and calling setsid() so they have no controlling terminals. This means opening /dev/tty doesn't work in test-running subprocesses. The parent process is still controlled by its invoking terminal (if any). If opening /dev/tty fails, 'open($tty,"+</dev/tty")' still makes $tty into a typeglob, causing us to try to close it.

So we need to rework the I/O device handling. We retain the preference for a controlling terminal (now also falling back to ttyname(0)) over a non-terminal STDERR.

If stderr isn't a terminal, look at stdin and see if it is. If so, figure out its device name and open that, with O_NOCTTY so that we don't start catching ^C signals that we want only the parent process to catch.

If we open a terminal output device, let's also write the messages into the log file.

Our tests use subprocesses created by Proc::Simple and calling
setsid() so they have no controlling terminals. This means opening
/dev/tty doesn't work in test-running subprocesses. The parent process
is still controlled by its invoking terminal (if any). If opening
/dev/tty fails, 'open($tty,"+</dev/tty")' still makes $tty into a
typeglob, causing us to try to close it.

This means that using "runtests.pl --promptOnErrorBeforeTearDown" and
hitting an error causes a prompt to be issued (in the log file only),
and after the user hits return, a close() is attempted on an object
that isn't a file handle, causing a fatal error, and the test exits
without cleaning up.

So we need to rework the I/O device handling. We retain the preference
for a controlling terminal (now also falling back to ttyname(0)) over
a non-terminal STDERR.

If stderr isn't a terminal, look at stdin and see if it is. If so,
figure out its device name and open that, with O_NOCTTY so that we
don't start catching ^C signals that we want only the parent process
to catch.

If we open a terminal output device, let's also write the messages
into the log file.

Co-authored-by: aider (gpt-5) <aider@aider.chat>
Copy link
Member

@lorelei-sakai lorelei-sakai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't really understand this, but I'm not sure anyone else would, either.
If this seems to do what you want, then it's fine.

I have one comment, but it's minor, feel free to resolve it you don't want to do anything with it.

# Fall back to the device backing STDIN without acquiring a controlling
# tty.
my $stdin_path = eval { ttyname(fileno(STDIN)) };
if ($stdin_path &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wrap this? It feels short.

@raeburn raeburn merged commit 62699e4 into dm-vdo:main Jan 30, 2026
6 checks passed
@raeburn raeburn deleted the waitForInput branch January 30, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants