mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Do not return ErrWouldBlock when writing nothing to PTY replica output
Previously, writing an empty string to the PTY replica output queue would return linux.ErrWouldBlock. This PR fixes this behavior to not return an error.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -1384,6 +1384,25 @@ 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)),
|
||||
|
||||
Reference in New Issue
Block a user