Merge pull request #9954 from thecodingwizard:fix-pty-eof

PiperOrigin-RevId: 609075893
This commit is contained in:
gVisor bot
2024-02-21 12:02:14 -08:00
2 changed files with 18 additions and 1 deletions
+1 -1
View File
@@ -155,7 +155,7 @@ func (l *lineDiscipline) setTermios(task *kernel.Task, args arch.SyscallArgument
if oldCanonEnabled && !l.termios.LEnabled(linux.ICANON) {
l.inQueue.mu.Lock()
l.inQueue.pushWaitBufLocked(l)
l.inQueue.readable = true
l.inQueue.readable = len(l.inQueue.readBuf) > 0
l.inQueue.mu.Unlock()
l.termiosMu.Unlock()
l.replicaWaiter.Notify(waiter.ReadableEvents)
+17
View File
@@ -1285,6 +1285,23 @@ TEST_F(PtyTest, SwitchNoncanonToCanonNoNewlineBig) {
ExpectFinished(replica_);
}
// If the canonical input buffer is empty, and we switch to non-canonical
// mode, the input buffer should not be readable.
TEST_F(PtyTest, SwitchCanonToNoncanonEmptyInput) {
constexpr char kInput[] = "";
ASSERT_THAT(WriteFd(master_.get(), kInput, sizeof(kInput)),
SyscallSucceedsWithValue(sizeof(kInput)));
DisableCanonical();
// Nothing available yet.
char buf[2] = {};
ASSERT_THAT(PollAndReadFd(replica_.get(), buf, 2, kTimeoutShort),
PosixErrorIs(ETIMEDOUT, ::testing::StrEq("Poll timed out")));
ExpectFinished(replica_);
}
// Tests that we can write over the 4095 noncanonical limit, then read out
// everything.
TEST_F(PtyTest, NoncanonBigWrite) {