rust-kernel
Rustbelt: a hobby x86_64 kernel written in Rust
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | //! Stage 14, the process model: fork with copy-on-write, execve with a
//! Linux-style initial stack, mmap and demand paging, signals, wait4, job
//! control. Most checks run inside the user test programs (forktest,
//! cowtest, mmaptest, sigtest: exit code = failed checks); this file starts
//! them and adds what only the kernel can see: memory leaks, the process
//! table limit, Ctrl+C from the keyboard.
extern crate alloc;
use ;
use ;
use PanicInfo;
use ;
use ;
entry_point!;
!
const BIN: &str = "/mnt/disk0/bin";
/// Writes in a forked child don't show up in the parent (and back),
/// MAP_SHARED pages are shared.
/// fork, wait4, execve, vfork, dup2 through pipes, a SIGSEGV'd child.
/// A program started by the kernel gets argv, envp and auxv exactly like
/// on Linux (AT_PHDR, AT_PAGESZ, AT_ENTRY, AT_RANDOM, AT_EXECFN...).
/// mmap/munmap/mprotect/brk, demand paging, and faults delivered to a
/// SIGSEGV handler that fixes them.
/// Without a handler, a bad write is SIGSEGV's default: terminate, 139.
/// Handlers + sigreturn, masks, default actions, SIGCHLD, stop/continue,
/// SIGPIPE, EINTR and SA_RESTART, kill on process groups.
/// wait4's status word, the way the W* macros decode it.
/// A fork bomb hits the process limit (EAGAIN) instead of eating all
/// memory, and after killing it everything is given back.
/// Many rounds of fork + exec + exit + wait: the frame count comes back
/// exactly (shared-frame refcounts drop to zero, page tables are freed).
/// Ctrl+C on the console: the tty sends SIGINT to the foreground process
/// group, and `spin` (which never makes a syscall) dies of it.
/// Ctrl+C with nobody in the foreground hits nobody.
!
|