xiaoxiang781216 opened a new pull request, #19184:
URL: https://github.com/apache/nuttx/pull/19184

   ## Summary
   Add lightweight job-control/controlling-terminal support for serial and PTY 
drivers on systems without a real POSIX session/process-group model.
   
   NuttX currently treats each task as its own process group. This patch keeps 
that model (`pgrp == pid`) and adds the missing APIs/ioctls needed by portable 
software such as dropbear/socat:
   
   - Add `TIOCGPGRP`, `TIOCSPGRP`, and `TIOCGSID` ioctl numbers.
   - Extend `serial.c` and `pty.c` to support:
     - `TIOCSCTTY`: `arg > 0` preserves the existing NuttX convention of 
passing an explicit target PID (used by NSH for foreground commands), while 
`arg == 0` follows POSIX-style flag semantics and selects the calling task.
     - `TIOCGPGRP` / `TIOCGSID`: return the current foreground PID.
     - `TIOCSPGRP`: set the foreground PID (or caller when pgrp is zero).
   - Add libc wrappers:
     - `tcgetpgrp()`, `tcsetpgrp()`, `tcgetsid()` over the new ioctls.
     - `setsid()`, `getsid()`, `setpgid()` stubs consistent with the existing 
single-member process-group model.
   - Document the behavior and limitations in 
`Documentation/components/drivers/character/serial.rst`.
   
   ## Rationale
   This avoids regressing existing NSH behavior where `TIOCSCTTY` is used to 
register a spawned foreground command as the Ctrl-C/Ctrl-Z signal target, while 
also supporting the POSIX-style `ioctl(fd, TIOCSCTTY, 0)` pattern used by 
dropbear and similar software.
   
   Group-broadcast signaling (`kill(-pgrp, signo)`) remains unsupported, so 
TTY-generated signals still target a single foreground PID.
   
   ## Testing
   - `git diff apache/master..HEAD | ./tools/checkpatch.sh -` completed 
successfully. The script reports only that `cmake-format` is not installed in 
this environment.
   - Cherry-picked cleanly onto current `apache/master` after resolving 
declaration/list-order conflicts with upstream `gettid()` / unistd Make.defs 
changes.
   
   A full `sim:nsh` build could not be completed from this local workspace 
because the checked-out `apps/` tree is not an upstream-compatible apps tree 
(`apps/examples/Kconfig` is missing). The patch itself is confined to NuttX 
serial/libc code and documentation.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to