25 Commits
Author SHA1 Message Date
Nicolas LacasseandgVisor bot 6b0a0af862 Implement basic packet mode support for ptys.
From man TIOCPKT:
"""
In packet mode, each subsequent read(2) will return a packet that either
contains a single nonzero control byte, or has a single byte containing zero
('\0') followed by data written on the slave side of the pseudoterminal."
"""

This CL implements only the data portion of packet mode, not the control bytes,
but that seems to be enough to get xfce4-terminal to work.

PiperOrigin-RevId: 737175092
2025-03-15 09:26:56 -07:00
gVisor bot 52af950390 Merge pull request #9954 from thecodingwizard:fix-pty-eof
PiperOrigin-RevId: 609075893
2024-02-21 12:02:14 -08:00
gVisor bot 3a73915fcc Merge pull request #9950 from thecodingwizard:master
PiperOrigin-RevId: 605691085
2024-02-09 11:47:53 -08:00
Ayush RanjanandgVisor bot cdededb792 Notify master waiter when all replicas are closed.
Fixes #9951
Fixes #9333

PiperOrigin-RevId: 605462571
2024-02-08 16:41:01 -08:00
Nathan Wang 0a818095d9 Add partial support for VERASE and VWERASE in canonical mode in PTYs 2024-02-08 01:59:41 +00:00
Nathan Wang ff34288f92 Fix EOFs when reading from empty canon->noncanon PTY
when switching from canonical to non-canonical mode, only mark inQueue as readable if there is input to be read
2024-02-02 23:50:03 +00:00
Nathan Wang 89c034566e 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.
2024-02-01 20:38:59 +00:00
Etienne PerotandgVisor bot 917bee5b6d Add a size limit to outputQueueTransformer.transform.
This applies a similar limit as `inputQueueTransformer.transform`.

The goal is to avoid large allocations of memory.

I'm not sure if this is the right thing to do, but it seems better than the
status quo of not having any limits.

PiperOrigin-RevId: 581034478
2023-11-09 14:59:32 -08:00
gVisor bot 0230a371c2 Merge pull request #9336 from thundergolfer:jonathon/dev-pts-eof-handling
PiperOrigin-RevId: 563199056
2023-09-06 13:29:19 -07:00
Jonathon Belotti e8c399a093 Fix EOF (^D) handling in devpts (partially addr #9333) 2023-09-06 01:18:18 +00:00
gVisor bot 243aeddd59 [pty] Return enqueued data and then EIO if the replica is closed
PiperOrigin-RevId: 532496868
2023-05-16 10:15:01 -07:00
Nicolas LacasseandgVisor bot 8184fa1db0 Clean up devpts code, and deduplicate the foreground process state.
We no longer store the foreground process directly in the terminal. Instead, we
get it from the terminal TTY's ThreadGroup. Added a new method:
tty.SignalForegroundProcessGroup to simplify this.

Cleaned up some things along the way:
* Terminal had a bunch of methods to get/set foreground process group and
  controlling TTY, but those methods were only usable by Ioctl, since they
  read/wrote to syscall arguments. I moved that logic to Ioctl, and deleted the
  methods from Terminal, which is now a very simple type.
* Fixed a bug in ThreadGroud.SetForegroundProcessGroup where we were
  overwriting the ID of an existing process group, rather than setting a new
  process group on the session.
* Simplified the construction of lineDiscipline type.

Reported-by: syzbot+ae5b769cec8ad969c086@syzkaller.appspotmail.com
PiperOrigin-RevId: 512330758
2023-02-25 14:08:58 -08:00
Wim a88680b765 Implement code review remarks 2023-02-23 13:16:56 +01:00
Wim 1dc92a8c71 Add reference to terminal in lineDiscipline 2023-02-22 22:33:37 +01:00
Wim 56458440b3 Support SIGQUIT 2023-02-19 20:00:26 +01:00
Wim a547fffe1e Support some PTY control characters 2023-02-19 17:08:17 +01:00
Ayush RanjanandgVisor bot f6ed4523dc Reformat codebase.
PiperOrigin-RevId: 449358041
2022-05-17 17:48:35 -07:00
Zach KoopmansandgVisor bot ce58d71fd5 [syserror] Remove pkg syserror.
Removes package syserror and moves still relevant code to either linuxerr
or to syserr (to be later removed).

Internal errors are converted from random types to *errors.Error types used
in linuxerr. Internal errors are in linuxerr/internal.go.

PiperOrigin-RevId: 390724202
2021-08-13 17:16:52 -07:00
Etienne PerotandgVisor bot 07f2c8b56b devpts: Notify of echo'd input queue bytes only after locks have been released.
PiperOrigin-RevId: 383684320
2021-07-08 12:04:56 -07:00
Bhasker HariharanandgVisor bot e7ca2a51a8 Add POLLRDNORM/POLLWRNORM support.
On Linux these are meant to be equivalent to POLLIN/POLLOUT. Rather
than hack these on in sys_poll etc it felt cleaner to just cleanup
the call sites to notify for both events. This is what linux does
as well.

Fixes #5544

PiperOrigin-RevId: 364859977
2021-03-24 12:11:44 -07:00
Jamie LiuandgVisor bot 9f87400f08 Support VFS2 save/restore.
Inode number consistency checks are now skipped in save/restore tests for
reasons described in greatest detail in StatTest.StateDoesntChangeAfterRename.
They pass in VFS1 due to the bug described in new test case
SimpleStatTest.DifferentFilesHaveDifferentDeviceInodeNumberPairs.

Fixes #1663

PiperOrigin-RevId: 338776148
2020-10-23 17:48:33 -07:00
Ayush RanjanandgVisor bot 2eaf54dd59 Refactor tty codebase to use master-replica terminology.
Updates #2972

PiperOrigin-RevId: 329584905
2020-09-01 14:43:41 -07:00
Ayush RanjanandgVisor bot 723fb5c116 [go-marshal] Enable auto-marshalling for fs/tty.
PiperOrigin-RevId: 329564614
2020-09-01 13:02:17 -07:00
Fabricio VoznikaandgVisor bot 20e6efd302 Remove IfChange/ThenChange lint from VFS2
As new functionality is added to VFS2, corresponding files in VFS1
don't need to be changed.

PiperOrigin-RevId: 312153799
2020-05-18 14:26:09 -07:00
Nicolas LacasseandgVisor bot 696feaf10c Port devpts to VFS2.
PiperOrigin-RevId: 308164359
2020-04-23 17:34:29 -07:00