nuttx/libs/libc/unistd
Xiang Xiao db9531fe96 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-08-06 17:48:04 +08:00
..
CMakeLists.txt drivers/serial: add job-control TTY ioctls and libc wrappers 2026-08-06 17:48:04 +08:00
Kconfig libc/unistd: move NAME_MAX/LINE_MAX/PATH_MAX define to unistd 2025-01-15 23:17:51 +08:00
lib_access.c libs: unify Private Types banners 2025-05-28 10:17:15 +08:00
lib_alarm.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_chdir.c libc/chdir: replace heap alloc to path buffer to improve performance 2024-12-11 20:33:34 +08:00
lib_confstr.c unistd: add support for confstr() 2025-08-22 20:50:13 +08:00
lib_crypt.c libs/libc/unistd: add crypt function 2024-10-16 11:15:25 +08:00
lib_crypt_r.c libs/libc/unistd:Fix errcode not return normally 2024-10-16 11:15:25 +08:00
lib_daemon.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_execl.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_execle.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_execv.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_fchdir.c libc/chdir: chdir/fchdir should not depend on environment variables 2024-12-11 00:34:25 +08:00
lib_fchownat.c Use lib_get_pathbuffer instead of stack variables 2024-11-12 17:21:42 +08:00
lib_flock.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_fork.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
lib_fstatvfs.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_futimes.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_getcwd.c nuttx: add get_current_dir_name implementation 2024-12-19 20:55:51 +08:00
lib_getegid.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_getentropy.c libc: Refine the arc4random_buf implementation 2024-10-26 18:04:21 -03:00
lib_geteuid.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_getgid.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_gethostname.c libs/libc: replace critical section with spinlock in hostname operations 2026-01-17 14:13:07 +08:00
lib_getopt.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_getopt_common.c style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
lib_getopt_long.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_getopt_longonly.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_getoptargp.c libc/unistd: fixed tasking build issue 2024-11-01 23:03:23 +08:00
lib_getopterrp.c libc/unistd: fixed tasking build issue 2024-11-01 23:03:23 +08:00
lib_getoptindp.c libc/unistd: fixed tasking build issue 2024-11-01 23:03:23 +08:00
lib_getoptoptp.c libc/unistd: fixed tasking build issue 2024-11-01 23:03:23 +08:00
lib_getoptvars.c style/FAR: remove FAR qualifier 2025-11-10 10:56:29 +01:00
lib_getpass.c libs/libc/unistd: add getpass function 2024-10-16 11:15:25 +08:00
lib_getpgid.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_getpgrp.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_getpriority.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_getrlimit.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_getrusage.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_getsid.c drivers/serial: add job-control TTY ioctls and libc wrappers 2026-08-06 17:48:04 +08:00
lib_getuid.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_linkat.c Use lib_get_pathbuffer instead of stack variables 2024-11-12 17:21:42 +08:00
lib_lockf.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_lutimes.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_nice.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_pathconf.c fpathconf: add _POSIX_PRIO_IO defintion 2026-01-15 16:10:51 -03:00
lib_pipe.c libc/unistd: Replace pipe() macro with proper function implementation 2025-11-26 17:18:13 +08:00
lib_posix_fallocate.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_readlinkat.c Use lib_get_pathbuffer instead of stack variables 2024-11-12 17:21:42 +08:00
lib_restoredir.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_setegid.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_seteuid.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_setgid.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_sethostname.c libs/libc: replace critical section with spinlock in hostname operations 2026-01-17 14:13:07 +08:00
lib_setpgid.c drivers/serial: add job-control TTY ioctls and libc wrappers 2026-08-06 17:48:04 +08:00
lib_setpriority.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_setregid.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_setreuid.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_setrlimit.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_setsid.c drivers/serial: add job-control TTY ioctls and libc wrappers 2026-08-06 17:48:04 +08:00
lib_setuid.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_sleep.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_statvfs.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_swab.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_symlinkat.c Use lib_get_pathbuffer instead of stack variables 2024-11-12 17:21:42 +08:00
lib_sysconf.c limits: add _POSIX_PTHREAD_ constant for pthread management 2026-01-16 16:15:35 +08:00
lib_times.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_truncate.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_ulimit.c lib_ulimit: fix the variable uninit coverity issue 2026-01-16 10:03:53 +08:00
lib_unlinkat.c Use lib_get_pathbuffer instead of stack variables 2024-11-12 17:21:42 +08:00
lib_usleep.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_utime.c libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00
lib_utimes.c Use lib_get_pathbuffer instead of stack variables 2024-11-12 17:21:42 +08:00
Make.defs drivers/serial: add job-control TTY ioctls and libc wrappers 2026-08-06 17:48:04 +08:00
unistd.h libs/libc: migrate to SPDX identifier 2024-10-01 12:25:52 +08:00