
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
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.
Jesse Storimer • Working With Unix Processes
Note that the hard limit on my system for the number of file descriptors is a ridiculously large integer. Is it even possible to open that many? Likely not, I'm sure you'd run into hardware constraints before that many resources
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
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 moreJesse Storimer • Working With Unix Processes
Unix processes have very few inherent ways of communicating about their state. Programmers have worked around this and invented things like logfiles. Logfiles allow processes to communicate anything they want about their state by writing to the filesystem, but this operates at the level of the filesystem rather than being inherent to the process it
... See moreJesse Storimer • Working With Unix Processes
A part of the Unix philosophy: in the land of Unix 'everything is a file'. This means that devices are treated as files, sockets and pipes are treated as files, and files are treated as files. Since all of these things are treated as files I'm going to use the word 'resource' when I'm talking about files in a general sense (including devices, pipes
... See moreJesse Storimer • Working With Unix Processes
We'll continue on the subject of file descriptors. Using Ruby we can ask directly for the maximum number of allowed file descriptors: p Process.getrlimit(:NOFILE) On my machine this snippet outputs: [2560, 9223372036854775807] We used a method called Process.getrlimit and asked for the maximum number of open files using the symbol :NOFILE. It retur
... See moreJesse Storimer • Working With Unix Processes
Every process on the system has a name. For example, when you start up an irb session that process is given the name 'irb'. The neat thing about process names is that they can be changed at runtime and used as a method of communication. In Ruby you can access the name of the current process in the $PROGRAM_NAME variable. Similarly, you can assign a
... See more