
Working With Unix Processes

Every process has access to a special array called ARGV. Other programming languages may implement it slightly differently, but every one has something called 'argv'. argv is a short form for 'argument vector'. In other words: a vector, or array, of arguments. It holds the arguments that were passed in to the current process on the command line.
... See moreJesse Storimer • Working With Unix Processes
Ruby's Process.pid maps to getpid(2). There is also a global variable that holds the value of the current pid. You can access it with $$. Ruby inherits this behaviour from other languages before it (both Perl and bash support $$), however I avoid it when possible. Typing out Process.pid in full is much more expressive of your intent than the
... See moreJesse Storimer • Working With Unix Processes
In much the same way as pids represent running processes, file descriptors represent open files.
Jesse Storimer • Working With Unix Processes
You can see that we set a new limit for the number of open files, and upon asking for that limit again both the hard limit and the soft limit were set to the new value 4096. We can optionally pass a third argument to Process.setrlimit specifying a new hard limit as well, assuming we have the permissions to do so. Note that lowering the hard limit,
... See moreJesse Storimer • Working With Unix Processes
On my system that number actually represents infinity. It's repeated in the constant Process::RLIMIT_INFINITY. Try comparing those two values to be sure. So, on my system, I can effectively open as many resources as I'd like, once I bump the soft limit for my needs. So any process is able to change its own soft limit, but what about the hard limit?
... See moreJesse Storimer • Working With Unix Processes
In the last chapter we looked at the fact that open resources are represented by file descriptors. You may have noticed that when resources aren't being closed the file descriptor numbers continue to increase. It begs the question: how many file descriptors can one process have? The answer depends on your system configuration, but the important
... See moreJesse Storimer • Working With Unix Processes
Ruby's Process.ppid maps to getppid(2).
Jesse Storimer • Working With Unix Processes
The VAR=value syntax is the bash way of setting environment variables. The same thing can be accomplished in Ruby using the ENV constant.
Jesse Storimer • Working With Unix Processes
Every Unix process comes with three open resources. These are your standard input (STDIN), standard output (STDOUT), and standard error (STDERR) resources. These standard resources exist for a very important reason that we take for granted today. STDIN provides a generic way to read input from keyboard devices or pipes, STDOUT and STDERR provide
... See more