Ending

Working with processes in Unix is about two things: abstraction and communication.

Abstraction

The kernel has an extremely abstract (and simple) view of its processes. As programmers we’re used to looking at source code as the differentiator between two programs.

We are masters of many programming languages, using each for different purposes. We couldn’t possibly write memory-efficient code in a language with a garbage collector, we’ll have to use C. But we need objects, let’s use C++. On and on.

But if you ask the kernel it all looks the same. In the end, all of our code is compiled down to something simple that the kernel can understand. And when it’s working at that level all processes are treated the same. Everything gets its numeric identifier and is given equal access to the resources of the kernel.

What’s the point of all this jibber-jabber? Using Unix programming lets you twiddle with these knobs a little bit. It lets you do things that you can’t accomplish when working at the programming language level.

Unix programming is programming language agnostic. It lets you interface your Ruby script with a C program, and vice versa. It also lets you reuse its concepts across programming languages. The Unix Programming skills that you get from Ruby will be just as applicable in Python, or node.js, or C. These are skills that are about programming in general.

Communication

Besides the basic act of creating new processes, almost everything else we talked about was regarding communication. Following the principle of abstraction mentioned above, the kernel provides very abstract ways of communicating between processes.

Using signals any two processes on the system can communicate with each other. By naming your processes you can communicate with any user who is inspecting your program on the command line. Using exit codes you can send success/failure messages to any process that’s looking after your own.

Farewell, But Not Goodbye

That’s the end! Congratulations for making it here! Believe it or not, you now know more than most programmers about the inner workings of Unix processes.

Now that you know the fundamentals you can go out apply your newfound knowledge to anything that you work on. Things are going to start making more sense for you. And the more you apply your newfound knowledge: the clearer things will become. There’s no stopping you now.

And we haven’t even talked about networking :) We’ll save that one for another edition.

Read the appendices at the end of this book for a look at some popular Ruby projects and how they use Unix processes to be awesome.

If you have any feedback on this book, find an error or build something cool with your newfound knowledge, I’d love to hear it. Send a message to jesse@jstorimer.com. Happy coding!