Check /cmdline for programe name as well as /exe.

This is useful for when the program was called via a symlink. For example on
my system `mplayer` is an alias to `mplayer2`. Since I launch it with
`mplayer` if I wanted to check the progress using cv I would expect to use `cv
-c mplayer` but that currently doesn't work. The original command line
(assuming argv[0] hasn't been modified) has this information:

    $ readlink `which mplayer`
    /etc/alternatives/mplayer
    $ readlink -f `which mplayer`
    /usr/bin/mplayer2

    $ readlink /proc/`pidof mplayer`/exe
    /usr/bin/mplayer2
    $ cat /proc/`pidof mplayer`/cmdline | tr '\0' ' ' | cut -d' ' -f1
    mplayer

Currently I am checking for a full basename match on the executable but it may
be nice to add a -f,--full like pgrep does. Also -g,--glob (fnmatch) my be
useful for partial matches with -c.

This adds an more overhead for every unsuccessful /exe lookup though :(. If
this becomes an option there are a couple of options like: only do this extra
check if -c was passed (but then symlinks for cp (eg from busybox) wouldn't
work), hiding it behind an option, caching.
Allow passing multiple names to -c comma delimited.

Might be nice to allow -c to be present on the CLI multiple times too.
Add alternatives section in readme.

Mostly from the HN thread: https://news.ycombinator.com/item?id=8023713
Add --verbose flag for tedious permission errors etc.

Using strerror instead of perror so we can print the pid/path info as well.
Add pid/path info to error messages.
Add --glob argument to use fnmatch() instead of strcmp().

Now you can eg `cv -gc chrome\*,mplay\*`.

Not sure about the flags to fnmatch, just read through the man page and
thought they looked appropriate.

Had to switch the printouts (`pid_list[N].name`) to use `basename(exe)` rather
than bn_name because printing out the search pattern with glob isn't all that
useful.
Add --full argument to match against the entire command line.

Matches the search pattern against the entire command line from
/proc/pid/cmdline instead of just the command name (argv[0]).
Since we are currently doing an exact match it is only really useful with eg
`cv -fgc \*pattern\*`. Hence implies `--glob`. If we do support substring
matches at some point it might be nice to make `-f` require `-c`.

Since this modifies the string that is copied to `pidinfo_list[i].name` it
could print the wrong process name in the info printout. Specifically since
the null characters from /proc/pid/cmdline are converted to spaces we lose the
distinction between arguments with spaces in them and argument delimiters.
Since we only care about the binary name here then this means that if your
binary has a space in it only the first bit of the name will be printed. This
is surely rare though, no processes in my PATH have spaces in the name.
Add --case-insensitive argument.

Converts the current binary name/command line to lower case before comparing.
Since this modifies the string that is saved to `pid_list[N].name` then if
your program hase capitals in the name it will be printed out wrong. The only
relevant procces in my PATH is GET.
Optimization: only go through /proc once.

Now instead of going through proc for each binary we are interested in go
through proc once and loop in the process names for each pid.

I wasn't actually seeing any performance issues so this is really a premature
optimisation...

The diff for `find_pids_by_binary_name` may look really big but that is only
because the indentation changed because of the new inner loop. The only thing
that changed in the inner loop is that I changed a couple of `break`s into
`goto`s to break out of the outer loop. If you don't like `goto`s you could
just add an additional `max_procs` check at the top of the outer loop.

Changed proc_names to be no longer null terminated just so it matches up with
the array generated from the `-c` argument.
Factor out "".split(",") method.

So that it can be used for other comma separated argument lists.
Add --directory argument to filter proc/fd list by directory.

Not implemented yet.
Allow to filter proc/fd results by directory.

Implement an `lsof` alike `-D` argument. Eg

    cv -gc \* -D /tmp

will look through all processes to see if they have a file open in /tmp. The
fd selection for the actual printout is also filtered although it is possible
to not filter it there, I can't think of a reason why you would want that
though.

Changes to the two main functions to accept directory filter arguments and to
accept NULL/0 for some values. If you call `find_fd_for_pid` with NULL for the
output list it will just return a count of interesting fds.

TODO: Only works for absolute paths at the moment. Need to use realpath.
Allow directory filter to user relative paths, symlinks.

Use realpath. I am re-using the fullpath array because I like premature
optimization.

Also, realpath expands all symlinks. This may lead to a confusing user
experience. Except that the links under /proc/pid/fd/ all have symlinks
expanded to so it is really unavoidable.
Allow to filter proc/fd results by size.

So now you can just check the seex status of any large files:

    cv -gc \* -S $((1024*1024*1024))

TODO: Implement size suffixes like 1M, 1m, 1G etc.

This argument is probably of dubious worth, but it wasn't hard to add it
anyway.