Job control, function keys, and real sleeps

- SIGSTOP/SIGTSTP/SIGTTIN/SIGTTOU stop, SIGCONT resumes; the parent gets
  SIGCHLD and wait4 reports WUNTRACED/WCONTINUED; ps shows T. Ctrl-Z works,
  and mc no longer hangs waiting for its subshell to stop.
- Blocking reads (console, pty, pipe) and sleeps take a pending stop and
  carry on after SIGCONT; a caught signal without SA_RESTART ends them
  with EINTR.
- nanosleep reads tv_nsec (sleep 0.5 used to return at once), writes the
  remainder, and clock_nanosleep understands TIMER_ABSTIME.
- rt_sigaction uses the k_sigaction layout for Linux-ABI processes: the old
  action's restorer was written 112 bytes past the caller's struct. Flags
  are kept; SIGKILL and SIGSTOP cannot be caught.
- F1..F12 reach programs, as the Linux console sends them (PS/2, USB, I2C).
- TIOCLINUX subcode 6 answers "no modifiers" instead of echoing the 6 back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
This commit is contained in:
Nexoniarz 2026-10-25 02:37:45 +01:00
commit 2372806862
13 changed files with 366 additions and 42 deletions

View file

@ -1653,6 +1653,20 @@ addr_t sys_ioctl(void)
// terminal and nothing to choose. It records the choice now, which is what
// /dev/tty resolves through and what a session leader on tty3 needs so
// that its /dev/tty is tty3 and not whatever is on screen.
// TIOCLINUX. Only subcode 6, the modifier state, is answered -- with
// "none held", which is true often enough. mc asks it after every key on
// a Linux console, and the ioctl used to succeed without writing: the 6
// it passed in came back as Ctrl+AltGr held, and Enter arrived as an
// unknown chord printed as a dot.
if (request == 0x541C) {
uchar sub;
if (copy_from_user(&sub, argp, 1) < 0)
return -EFAULT;
if (sub != 6)
return -EINVAL;
sub = 0;
return copy_to_user(argp, &sub, 1) < 0 ? -EFAULT : 0;
}
if (request == TIOCSCTTY) {
struct vt *v = vt_for_minor(f->ip->minor);
myproc()->ctty = vt_index(v) + 1;