diff --git a/kernel/proc/proc.c b/kernel/proc/proc.c index 3d91ad6..0a19da2 100644 --- a/kernel/proc/proc.c +++ b/kernel/proc/proc.c @@ -478,6 +478,13 @@ fork(void) // POSIX: the child inherits process group, session and all four ids. np->pgid = myproc()->pgid; np->sid = myproc()->sid; + // The controlling terminal is a property of the *session*, so it crosses + // fork() with the session id rather than being re-established. It was set + // only by TIOCSCTTY and never inherited, so every child of a shell had + // ctty 0 -- which is why plain `ps` listed the shell and nothing it had + // started, background jobs included. A job that is running on your terminal + // is on your terminal whoever forked it. + np->ctty = myproc()->ctty; np->uid = myproc()->uid; np->euid = myproc()->euid; np->suid = myproc()->suid; np->gid = myproc()->gid; np->egid = myproc()->egid; np->sgid = myproc()->sgid;