
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
In the majority of cases the parent process for a given process is the process that invoked it. For example, you're an OSX user who starts up Terminal.app and lands in a bash prompt. Since everything is a process that action started a new Terminal.app process, which in turn started a bash process. The parent of that new bash process will be the Ter
... See moreJesse 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 ge
... See moreJesse 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
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 dollar
... See moreJesse Storimer • Working With Unix Processes
Ruby's Process.ppid maps to getppid(2).
Jesse Storimer • Working With Unix Processes
You can use these same methods to check and modify limits on other system resources. Some common ones are: # The maximum number of simultaneous processes # allowed for the current user. Process.getrlimit(:NPROC) # The largest size file that may be created. Process.getrlimit(:FSIZE) # The maximum size of the stack segment of the # process. Process.g
... See moreJesse Storimer • Working With Unix Processes
File descriptors are at the core of network programming using sockets, pipes, etc. and are also at the core of any file system operations. Hence, they are used by every running process and are at the core of most of the interesting stuff you can do with a computer.
Jesse Storimer • 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. He
... See more