]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
feat: shell job control (&, &&, ||) and CTRL+C/CTRL+Z support
authorTulio A M Mendes <[email protected]>
Tue, 17 Feb 2026 07:15:18 +0000 (04:15 -0300)
committerTulio A M Mendes <[email protected]>
Tue, 17 Feb 2026 07:15:18 +0000 (04:15 -0300)
commit684d84b0ed8ca035597be1807b6659268fad8035
treed223af3726ea2255087ea358186fdfa5c0e0298e
parentf34b43b3596a9b54eb93ccd6aae610ce375dd117
feat: shell job control (&, &&, ||) and CTRL+C/CTRL+Z support

1. Background processes (&): trailing & forks without waiting, prints
   [bg] PID. Works for simple commands and pipelines.

2. Command chaining (&&): executes next command only if previous
   succeeded (exit status 0). Skips remaining && chain on failure
   until a || or ; is found.

3. OR chaining (||): executes next command only if previous failed
   (exit status != 0). Skips remaining || chain on success until
   a && or ; is found.

4. CTRL+C / CTRL+Z: shell ignores SIGINT/SIGTSTP/SIGQUIT. Child
   processes get their own process group (setpgid) and are set as
   the foreground group (TIOCSPGRP). CTRL+C sends SIGINT only to
   the child, not the shell. After child exits, shell restores
   itself as foreground group.

New files:
- user/ulibc/include/sys/wait.h: WIFEXITED/WIFSIGNALED/etc macros

Modified:
- user/sh.c: process_line rewritten for ;/&&/||/& operators,
  run_simple and run_pipeline use setpgid+TIOCSPGRP job control
- user/ulibc/include/termios.h: added TIOCSPGRP/TIOCGPGRP
user/sh.c
user/ulibc/include/sys/wait.h [new file with mode: 0644]
user/ulibc/include/termios.h