How it works...
The Linux OS is largely file-based; many important interfaces to the kernel can be found in virtual filesystems pretending to be a file or folder structure. The best example is the /proc/ filesystem, which allows user-access to hardware and other current information of the kernel/system. In the same spirit, the console inputs and outputs are treated; they are actually reserved file handles with the numbers 0 (standard input), 1 (standard output), and 2 (standard error). In fact, these link back to the /proc/ filesystem, where /proc/<process id>/fd/1 is the standard output of that particular process ID.
Keeping this concept in mind, these file descriptors can be read just like any other file—which is what we are doing in this ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access