errno: -1 is EPERM, and four places were saying it by accident
Ctrl-C killed the shell. consoleread() breaks off the read in progress when
SIGINT arrives and returned -1 to do it -- and -1 is -EPERM by the time it
reaches a program, so every program that handles SIGINT by carrying on saw a
permanent error instead of an interrupted call:
zsh: error on TTY read: operation not permitted
schinitd: restarting os.schos.console-shell
and the next Ctrl-C did it to the replacement. EINTR now, which is what a
signal-interrupted read is required to give. Verified: Ctrl-C an interruptible
command, shell survives, zero restarts.
Same mistake, same file family: link, unlink, rename and renameat returned -1
on every error path. Callers branch on errno -- `if (unlink(p) < 0 && errno !=
ENOENT)` is the standard shape, and against EPERM it always complains -- which
is why zsh reported failures for things that had worked. They return ENOENT,
EEXIST, EXDEV, EISDIR, ENOTEMPTY and EFAULT now. About ninety other `return -1`s
remain in sys_fs.c; these four are done because these four were what a program
tripped over. /dev/mem's unknown minors return ENODEV rather than -1 too.
/dev/urandom was a linear congruential generator seeded with a **constant**, so
every boot produced the same bytes in the same order -- not weak, the same. A
key, a nonce, a temporary filename: shared with every SchOS machine that had
ever run. Seeded at boot from RDRAND where the CPU has it, from the cycle
counter and the wall clock where it does not, and re-stirred per byte. Still an
LCG and still not a CSPRNG; what changed is the part that was dangerous rather
than merely poor.
**Not fixed, and recorded as such:** rename() still will not replace an existing
target, so zsh's history save fails on every exit after the first. An attempt to
unlink the target first was reverted -- the directory is an HTree, dirunlink
followed by dirlink of the same name did not behave, and it panicked in
filewrite with the old file already gone. Losing both files is worse than
refusing, so it refuses until the HTree's slot reuse is understood.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ7Qx8E1q1M1bbCq8QLHS2
This commit is contained in:
parent
eacb13ce35
commit
75ccf9841c
11 changed files with 330 additions and 42 deletions
|
|
@ -507,8 +507,11 @@ note_exit(unsigned int cookie, int pid, int status)
|
|||
// job that was killed or faulted never matches this and is restarted the
|
||||
// way KeepAlive promises. See SCHINIT_EXIT_NORESTART.
|
||||
if ((status & 0x7f) == 0 && ((status >> 8) & 0xff) == SCHINIT_EXIT_NORESTART) {
|
||||
out("schinitd: "); out(j->label);
|
||||
out(" has nothing to do on this machine; not restarting\n");
|
||||
// Not a failure: the job looked, found the machine did not have what
|
||||
// it drives, and said so properly. Worth reading once and not every
|
||||
// boot on a machine that will never have one.
|
||||
vout("schinitd: "); vout(j->label);
|
||||
vout(" has nothing to do on this machine; not restarting\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -640,6 +643,17 @@ main(void)
|
|||
|
||||
vout("schinitd: ready\n");
|
||||
|
||||
// The one line a working boot prints, and the last one.
|
||||
//
|
||||
// Here rather than in the kernel because "the machine is up" is not true
|
||||
// until the jobs that make it usable have been started, and because
|
||||
// anything printed before this point would come after it on screen. The
|
||||
// kernel's whole boot is a kinfo() and is in the klog; this is the part a
|
||||
// person is meant to read.
|
||||
if (!verbose_boot)
|
||||
out("\nWelcome to SchOS!"
|
||||
" (F8 at boot for the full log, or dmesg once you are in)\n\n");
|
||||
|
||||
// From here on this program does two things: answer PID 1's heartbeat, and
|
||||
// act on the exits it reports. There is no wait() in this program and
|
||||
// there cannot be -- the children are not ours.
|
||||
|
|
|
|||
Loading…
Reference in a new issue