Jesse Storimer's Blog Archives tagged Unix

Industrial strength signal handling in Ruby - August 16, 2013

This is a video clip from the latest edition of my Unix fu workshop, an online course about Unix programming for Ruby folk. Give it a watch to see part of the fun where we do industrial-strength signal handling (deferred signal handlers and the self-pipe trick) for a pre-forking web server we built. If you like it, sign up for ...
Read more

[Screencast] Faster Rails test runs...with Unix! - June 19, 2013

Anybody who works on a moderate size Rails app can probably tell you: it takes forever to run a single test. I've definitely experienced this with some of the big Rails projects I've worked on, and it sucks! Goodbye productivity. Some smart people have been advocating ways around this. But if you've got an existing app, seeing the full benefit of these techniques involves ...
Read more

Is lock-free logging safe? - May 30, 2013

This is a bit of an odd question without some context. Recently, I saw the mono_logger project. It claims to provide "a lock-free Logger for Ruby 2.0". When I saw it I thought "Cool! I want to see what tricks they used to implement this". It looked pretty straightforward at first. When I looked closer and compared it to Logger ...
Read more

Grow Your Unix Beard Using Ruby - November 27, 2012

The video of my Rubyconf talk was posted this week by the fine folks over at Confreaks. The talk introduces basic concepts in Unix system programming, namely: fork+exec. It walks through examples that use these system calls in Ruby, at a high level, then how Unicorn uses them. If you don't time to watch the talk, just skip to 18:00 ...
Read more

Daemon Processes in Ruby - April 19, 2012

This is a sample chapter from my book Working With Unix Processes. Learning how stuff works under the hood is one of the most important things you can do as a developer. If this article pushes you in that direction then I encourage you to learn more about the book. Daemon processes are processes that run in the background, rather ...
Read more

Introduction to IPC in Ruby - April 19, 2012

This is a sample chapter from my book Working With Unix Processes. Learning how stuff works under the hood is one of the most important things you can do as a developer. If this article pushes you in that direction then I encourage you to learn more about the book. Up until now we've looked at related processes that share ...
Read more

A Unix Shell in Ruby - Part 4: Pipes - March 18, 2012

  Previously, in this series, we looked at interacting with environment variables (like PATH). In this article we'll investigate a peculiarity. It will reveal an impostor and eventually lead to implementing shell pipelines. First, the Peculiarity Observe these interactions with the shirt shell: $ ./shirt $ ls LICENSE README shirt $ ls | grep README README $ ls > output.txt $ cat ...
Read more

A Unix Shell in Ruby - Part 3: A Login Shell and the PATH - March 10, 2012

Previously, in this series, we saw how to implement some shell built-ins that are really necessary for the shell to function. This time, we'll make sure our shell can be used as a login shell and see how to interact with environment variables. First, A Word of Warning In this article I'm going to set up shirt as the default ...
Read more

A Unix Shell in Ruby - Part 2: Builtins - February 21, 2012

Welcome to the second article in this series. Last time we implemented a verrrry basic shell that could just run most basic commands. This time around we're going to look at how it's broken and how we can fix it. First up, we'll need a few builtins. A Note on Launching Last time I explained the semantics of exec: a call ...
Read more

A Unix Shell in Ruby - February 16, 2012

This is the first article in a series where I'll implement a Unix shell in pure Ruby code. Why a shell? A shell is the quintessential example of a Unix program. It hits all of the interesting points that a Unix system is capable of. It has to read input from STDIN, spawn processes requested from users, send signals to ...
Read more

11 Resources for Learning Unix Programming - February 10, 2012

Recently I got an email from a reader of WWUP asking how I learned about all this stuff. Here's what I told him. I personally get a lot from reading source code and from piecing together different resources. I have very little experience with C programming, and learned everything I know about Unix programming w/o having to write C code. ...
Read more

Exit, Exit! Abort, Raise…Get Me Outta Here! - January 19, 2012

I guest-posted over on rubysource.com about exit codes, why they're important, and how to use them from your Ruby programs. It's worth a read.
Read more

When to use STDERR instead of STDOUT - December 29, 2011

stdout and stderr both quack the same, but are used for very different purposes. Every process is initialized with three open file descriptors, stdin, stdout, and stderr. stdin is an abstraction for accepting input (from the keyboard or from pipes) and stdout is an abstraction for giving output (to a file, to a pipe, to a console). That's a very ...
Read more

The rails command and exec(2) - December 20, 2011

TL;DR: The sole job of the rails command that ships with the rails gem is to exec ./script/rails in your Rails project. Combine that with Aaron's PSA and that can be considerable overhead. You should use ./script/rails instead of rails. Ah, the rails command. Chances are that if you're writing Ruby code: you're using the rails command all the time. ...
Read more

On Colorized Output - December 16, 2011

Colorized output should be configurable. This is a followup to my last post. In that post I said: When you are piping output to another program you should always send plain, unformatted text. Unix utilities expect to deal with plain text. A redditor commented on that post to this effect: (paraphrasing is mine) Modern pagers and other programs can handle ...
Read more