Skip to content

Kernel swap (KSSF): fix context, return code, allocation-failure and redirection handling - #190

Open
nakatamaho wants to merge 9 commits into
FDOS:masterfrom
FreeDOS-88VA:kswap-state-fixes
Open

nakatamaho wants to merge 9 commits into
FDOS:masterfrom
FreeDOS-88VA:kswap-state-fixes

Conversation

@nakatamaho

Copy link
Copy Markdown

Fixes #189.

Kernel-swap (KSSF / CALL /S) fixes on top of current master. None of the touched files changed since com086, so the commits apply cleanly; each commit is self-contained.

  1. Environment backup registration (shell/kswap.c): register the segment and size of the environment backup at swap time. The previous code registered an offset (a narrowed far pointer), and a shell
    whose environment was resized with /E: could overrun the early allocation.
  2. Dynamic context across reload (shell/kswap.c, include/context.h, tools/kssf.asm): keep the dynamic context (aliases, history, /LOW policy and its counters) allocated across the shell's exit and
    return its ownership to the reloaded shell.
  3. Child return code (tools/kssf.asm): preserve the swapped program's DOS return code across the shell reload, so ERRORLEVEL is correct afterwards.
  4. Allocation-failure fallback (shell/kswap.c): if the backup allocation fails, execute the command without swapping instead of loading STRINGS while memory is exhausted (which could prompt for a
    resource file); the warning is written through the resident DOS writer.
  5. Child status vs. EXEC errors (lib/exec1.c, shell/kswap.c, tools/kssf.asm, criter/context.x, include/misc.h): keep the child's exit status separate from DOS EXEC errors, so a normal exit code
    (for example 7) is no longer reported as an MCB-corruption error.
  6. 8086 compatibility (tools/kssf.asm): restrict the expanded reload branch of KSSF to 8086 instructions (CPU 8086), so it runs on 8086/V30-class machines.
  7. No swap for redirection, pipes and batch files (shell/command.c): the swap ends the shell process, so DOS closes redirected and piped handles and the batch/FOR context is lost (with /SWAP, prog > file left an empty file). These cases, which docs/k-swap.txt lists as unsupported, now run with an ordinary EXEC.

A documentation commit removes a reference to a test directory that is not part of this tree.

Built with Open Watcom 1.9 (build.sh wc english) and NASM 2.15 (kssf.asm) on current master. Behavior was exercised on an emulated PC-88VA (shell started through KSSF with /SWAP and CALL /S, return to
the reloaded shell, ERRORLEVEL after a swapped program, redirected output). It has not been run on a standard PC with this branch.

(cherry picked from commit 2e76de3)
(cherry picked from commit bf4cd61)
(cherry picked from commit f957976)
(cherry picked from commit 76f1aac)
(cherry picked from commit 820f994)
(cherry picked from commit f2bcfe7)
(cherry picked from commit 376c5b7)
(cherry picked from commit 9ccd11c)
(cherry picked from commit bb7037a)
(cherry picked from commit 67dd684)
(cherry picked from commit fd2b3eb)
(cherry picked from commit 8cdffa3)
…diagnostics

(cherry picked from commit 52dd9a9)
(cherry picked from commit 9b3dedb)
The swap terminates the shell process: DOS closes the redirected or piped
handles and the batch/FOR context is lost, so the program wrote to the
console and the target file stayed empty under /SWAP. docs/k-swap.txt lists
these cases as unsupported; fall back to an ordinary EXEC for them.

(cherry picked from commit b646c55)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kernel swap (KSSF/CALL /S): state, return code and allocation-failure defects

1 participant