Merge pull request #9956 from thecodingwizard:pty-empty-write

PiperOrigin-RevId: 603485764
This commit is contained in:
gVisor bot
2024-02-01 14:40:57 -08:00
2 changed files with 22 additions and 5 deletions
+2 -5
View File
@@ -271,11 +271,8 @@ func (l *lineDiscipline) outputQueueWrite(ctx context.Context, src usermem.IOSeq
if err != nil {
return 0, err
}
if n > 0 {
l.masterWaiter.Notify(waiter.ReadableEvents)
return n, nil
}
return 0, linuxerr.ErrWouldBlock
l.masterWaiter.Notify(waiter.ReadableEvents)
return n, nil
}
// replicaOpen is called when a replica file descriptor is opened.
+20
View File
@@ -1384,6 +1384,26 @@ TEST_F(PtyTest, PartialBadBuffer) {
EXPECT_THAT(munmap(addr, 2 * kPageSize), SyscallSucceeds()) << addr;
}
// Test that writing nothing to the PTY replica's output queue does not return
// an error.
TEST_F(PtyTest, ReplicaWriteNothingCanonical) {
constexpr char kInput[] = "";
EXPECT_THAT(WriteFd(replica_.get(), kInput, strlen(kInput)),
SyscallSucceedsWithValue(strlen(kInput)));
ExpectFinished(master_);
}
TEST_F(PtyTest, ReplicaWriteNothingNonCanonical) {
DisableCanonical();
constexpr char kInput[] = "";
EXPECT_THAT(WriteFd(replica_.get(), kInput, strlen(kInput)),
SyscallSucceedsWithValue(strlen(kInput)));
ExpectFinished(master_);
}
TEST_F(PtyTest, SimpleEcho) {
constexpr char kInput[] = "Mr. Eko";
EXPECT_THAT(WriteFd(master_.get(), kInput, strlen(kInput)),