
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
What's the difference? Glad you asked. The soft limit isn't really a limit. Meaning that if you exceed the soft limit (in this case by opening more than 2560 resources at once) an exception will be raised, but you can always change that limit if you want
Jesse Storimer • Working With Unix Processes
Why do manpages need multiple sections? Because a command may be available in more than one section, ie. available as both a shell command and a system call. Take stat(1) and stat(2) as an example. In order to access other sections of the manpages you can specify it like this on the command line: $ man 2 getpid $ man 3 malloc $ man find # same as m
... See moreJesse Storimer • Working With Unix Processes
Ruby's Process.ppid maps to getppid(2).
Jesse Storimer • Working With Unix Processes
Many methods on Ruby's IO class map to system calls of the same name. These include open(2), close(2), read(2), write(2), pipe(2), fsync(2), stat(2), among others.
Jesse Storimer • Working With Unix Processes
Environment variables are often used as a generic way to accept input into a command-line program. Any terminal (on Unix or Windows) already supports them and most programmers are familiar with them. Using environment variables is often less overhead than explicitly parsing command line options.
Jesse Storimer • Working With Unix Processes
There are no system calls for directly manipulating environment variables, but the C library functions setenv(3) and getenv(3) do the brunt of the work. Also have a look at environ(7) for an overview.
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
Just knowing the pid isn't all that useful in itself. So where is it used? A common place you'll find pids in the real world is in log files.