Nixers Book Club - Book #1: The UNIX Programming Environment - Community & Forums Related Discussions

Users browsing this thread: 1 Guest(s)
Long time nixers
I have a couple of notes as well. I tried to focus on the little details (kind of -- maybe not really).

Chapter 1

One of the more interesting aspects of this chapter is how they describe the computing world of that era. Venam summed it up pretty nicely. This made much more impact on me when I first read it, but that was many years ago and I don’t remember anymore … :(

Quote:If you don’t know what a file is …

Funny, we’ll soon be making this same remark, now that files are no longer really visible on mobile devices. Imagine future kids, who grew up with nothing but a tablet, rediscovering the concept of a file.

Quote:There is, however, an older editor called ed

Cute, even when this book was written, ed was already considered to be “old(er)”. :)

Quote:/usr/mary … /usr/bin

Home directories and special directories thrown together? How odd.

Chapter 2

Quote:Everything in the UNIX system is a file.

Ha, there it is! Take that, Benno Rice! (No, just kidding, he has some valid points in that talk.)

To be honest, I’m not 100% sure what this sentence means in the context of this book. I suspect that their point is more about “everything is a file and a file is just a sequence of bytes”. A few paragraphs later, they tell you that other systems had more abstract concepts like “records”. Meaning, you probably were able to tell the system: “Give me record #5” and the kernel would do that. The kernel, not the program running in userspace! Stuff like that doesn’t exist in UNIX. When you want to get the fifth line, you have to figure it out yourself.

This applies to pipes as well. I’m really not an expert on Windows, but it appears PowerShell works differently these days:

Get-Process notepad,mspaint | Stop-Process

This is supposed to kill all running instances of notepad and paint. The way I understand it, this actually passes an object to the second command “Stop-Process”. Totally different from UNIX, where you explicitly have to do something like this:

pgrep xiate | while read; do kill "$REPLY"; done

This approach certainly makes for a simpler kernel, but it puts the entire burden on userspace programs.

Later in the chapter, they imply that the concept of “everything is a file” is extended on hardware as well. However: All the examples they give are simple character devices or block devices. Hardware like sound cards, where you have to negotiate a sample rate and sample format before you can just dump bytes into the device, is more complicated. This is where the “everything is a file” approach begins to become impractical. Let alone the USB stuff that Benno Rice talks about.


A nice explanation of what Ctrl-d does. No, it does not “send an EOF character”, as many people believe. It flushes a buffer.

Like phillbush, I originally learned this from this book and have since quoted it a lot. :)

Quote:The x field in the permissions of a directory does not mean exection; it means “search”. Execute permissions on a directory determines whether the directory may be searched for a file.

That’s remarkably confusing. When I first read that, I thought --x means you can only list directory contents (so you can search for a given file), but not the file contents. The opposite is true and the following sentences clarify it.

(21-11-2020, 11:00 AM)phillbush Wrote: One of the differences from old UNIX and modern UNIX is that you can no longer open(2) or read(2) a directory.
For example, the book opens a directory with od(1) to see its contents.
This is no longer possible in modern systems.

This is relatively “new”, IIRC. Something like 10 years ago, you could still run cat on a directory on FreeBSD.

(21-11-2020, 11:33 AM)venam Wrote: cat today doesn't have the `-u` unbuffered flag anymore.

It’s still there on OpenBSD:

Messages In This Thread
RE: Nixers Book Club - Book #1: The UNIX Programming Environment - by movq - 21-11-2020, 11:42 AM