shared: add PTY helper

This Pty API wraps the ugliness that is POSIX PTY. It takes care of:
  - edge-triggered HUP handling (avoid heavy CPU-usage on vhangup)
  - HUP vs. input-queue draining (handle HUP _after_ draining the whole
    input queue)
  - SIGCHLD vs. HUP (HUP is no reliable way to catch PTY deaths, always
    use SIGCHLD. Otherwise, vhangup() and friends will break.)
  - Output queue buffering (async EPOLLOUT handling)
  - synchronous setup (via Barrier API)

At the same time, the PTY API does not execve(). It simply fork()s and
leaves everything else to the caller. Usually, they execve() but we
support other setups, too.

This will be needed by multiple UI binaries (systemd-console, systemd-er,
...) so it's placed in src/shared/. It's not strictly related to
libsystemd-terminal, so it's not included there.
This commit is contained in:
David Herrmann
2014-07-17 11:39:48 +02:00
parent a2da110b78
commit a47d1dfd08
5 changed files with 870 additions and 0 deletions
+1
View File
@@ -204,6 +204,7 @@
/test-path-util
/test-prioq
/test-ratelimit
/test-pty
/test-replace-var
/test-resolve
/test-ring