Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> The new process [ls -l] gets the desired data, sends it to the shell and terminates.

> The shell sends the data to the terminal through the STDOUT side of the pty

Unless redirected, ls inherits the pty file descriptor from the shell¹ when the shell forks it. But after that, it's writing to the terminal emulator directly, not to the shell; that is, the shell doesn't forward `ls -l`'s output to the terminal.

¹(or really, the child inherits whatever file descriptor the shell has for stdin, stdout, stderr for its stdin, stdout, stderr, respectively, unless, for each of those, there is a redirection specified, in which case the shell replaces the file descriptor in the child as specified by the command give to the shell. stdin/stdout/stderr might be a pty in the shell, or they might not be.)



True, and thanks for pointing this out. But this example is there to illustrate the basic relationship of shell<->terminal-emulator without going in to too much details that might confuse those readers for whom it is intended.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: