mirror of
https://github.com/apache/nuttx.git
synced 2026-10-12 08:40:20 +00:00
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> |
||
|---|---|---|
| .. | ||
| CMakeLists.txt | ||
| Kconfig | ||
| lib_access.c | ||
| lib_alarm.c | ||
| lib_chdir.c | ||
| lib_confstr.c | ||
| lib_crypt.c | ||
| lib_crypt_r.c | ||
| lib_daemon.c | ||
| lib_execl.c | ||
| lib_execle.c | ||
| lib_execv.c | ||
| lib_fchdir.c | ||
| lib_fchownat.c | ||
| lib_flock.c | ||
| lib_fork.c | ||
| lib_fstatvfs.c | ||
| lib_futimes.c | ||
| lib_getcwd.c | ||
| lib_getegid.c | ||
| lib_getentropy.c | ||
| lib_geteuid.c | ||
| lib_getgid.c | ||
| lib_gethostname.c | ||
| lib_getopt.c | ||
| lib_getopt_common.c | ||
| lib_getopt_long.c | ||
| lib_getopt_longonly.c | ||
| lib_getoptargp.c | ||
| lib_getopterrp.c | ||
| lib_getoptindp.c | ||
| lib_getoptoptp.c | ||
| lib_getoptvars.c | ||
| lib_getpass.c | ||
| lib_getpgid.c | ||
| lib_getpgrp.c | ||
| lib_getpriority.c | ||
| lib_getrlimit.c | ||
| lib_getrusage.c | ||
| lib_getsid.c | ||
| lib_getuid.c | ||
| lib_linkat.c | ||
| lib_lockf.c | ||
| lib_lutimes.c | ||
| lib_nice.c | ||
| lib_pathconf.c | ||
| lib_pipe.c | ||
| lib_posix_fallocate.c | ||
| lib_readlinkat.c | ||
| lib_restoredir.c | ||
| lib_setegid.c | ||
| lib_seteuid.c | ||
| lib_setgid.c | ||
| lib_sethostname.c | ||
| lib_setpgid.c | ||
| lib_setpriority.c | ||
| lib_setregid.c | ||
| lib_setreuid.c | ||
| lib_setrlimit.c | ||
| lib_setsid.c | ||
| lib_setuid.c | ||
| lib_sleep.c | ||
| lib_statvfs.c | ||
| lib_swab.c | ||
| lib_symlinkat.c | ||
| lib_sysconf.c | ||
| lib_times.c | ||
| lib_truncate.c | ||
| lib_ulimit.c | ||
| lib_unlinkat.c | ||
| lib_usleep.c | ||
| lib_utime.c | ||
| lib_utimes.c | ||
| Make.defs | ||
| unistd.h | ||