nuttx/libs/libc/termios
Xiang Xiao 95063bde15 drivers/serial: add job-control TTY ioctls and libc wrappers
NuttX has no real session/process-group abstraction, so the TTY layer
collapses the foreground process group onto the single dev->pid field
(pgrp == pid, one member per group).  Extend the controlling-terminal
support so portable software (e.g. dropbear, socat) that relies on
job-control primitives works without losing the existing NuttX-specific
behaviour.

Driver (serial.c, pty.c):
- TIOCSCTTY now accepts a flag: arg > 0 keeps the historical "target
  PID in arg" semantics (NSH registers the foreground command it just
  spawned), while arg == 0 selects the calling task via
  nxsched_getpid(), matching the POSIX flag convention used by
  dropbear/socat/apue.  This preserves all existing callers and makes
  the previously-dead arg==0 path deliver SIGINT correctly.
- Add TIOCGPGRP/TIOCGSID (return dev->pid) and TIOCSPGRP (set it).
- pty.c gains the same handlers against pd_pid and includes
  nuttx/sched.h for nxsched_getpid().

ioctl numbers (tioctl.h): TIOCGPGRP/TIOCSPGRP/TIOCGSID at 0x37-0x39.

libc wrappers:
- termios: tcgetpgrp(), tcsetpgrp(), tcgetsid() over the new ioctls.
- unistd: setsid()/getsid()/setpgid() stubs consistent with the
  existing getpgrp()/getpgid() single-session model (sid == pgid ==
  pid; setpgid only succeeds for pgid == pid).

Declare the new prototypes in unistd.h (tcgetsid was already in
termios.h) and register all sources in the Make.defs/CMakeLists.

Group-broadcast signalling (kill(-pgrp)) remains unsupported, so
tty signals still target the single dev->pid; a real session/process
group model is left as a follow-up.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-06-23 16:26:53 -03:00
..
CMakeLists.txt drivers/serial: add job-control TTY ioctls and libc wrappers 2026-06-23 16:26:53 -03:00
lib_cfmakeraw.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_cfspeed.c libs: unify Private Types banners 2025-05-28 10:17:15 +08:00
lib_isatty.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_tcdrain.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_tcflow.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_tcflush.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_tcgetattr.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_tcgetpgrp.c drivers/serial: add job-control TTY ioctls and libc wrappers 2026-06-23 16:26:53 -03:00
lib_tcgetsid.c drivers/serial: add job-control TTY ioctls and libc wrappers 2026-06-23 16:26:53 -03:00
lib_tcsendbreak.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_tcsetattr.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_tcsetpgrp.c drivers/serial: add job-control TTY ioctls and libc wrappers 2026-06-23 16:26:53 -03:00
lib_ttyname.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_ttynamer.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
Make.defs drivers/serial: add job-control TTY ioctls and libc wrappers 2026-06-23 16:26:53 -03:00