foundry
Foundry OS: the operating system built on the Rustbelt kernel
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 | //! getty [-1] DEVICE -- run a shell on another terminal, e.g. /dev/hvc0.
//!
//! Real Unix systems run one "getty" per terminal line: it opens the line
//! and starts a login shell on it. Ours skips the login. Since stage 15 it
//! does it the classic Unix way, with fork + exec:
//!
//! 1. fork: the child will become the shell.
//! 2. setsid (in the child): a new *session* with no terminal yet.
//! 3. open DEVICE: a session leader without a terminal that opens one
//! gets it as its *controlling terminal*. That's what lets ^C on
//! that terminal send SIGINT to the right programs.
//! 4. dup2 it onto fds 0, 1 and 2 (stdin, stdout, stderr).
//! 5. execve the shell: it keeps the fds and the session.
//!
//! getty waits for the shell; when it exits (`exit`) a new one starts,
//! unless `-1` was given.
//!
//! Try it: `getty /dev/hvc0 &` here, then on the host
//! `socat - UNIX-CONNECT:target/hvc0.sock` and type commands.
use *;
const SHELL: &str = "/mnt/disk0/bin/sh";
/// The child's side (steps 2-5). Only returns on failure.
|