restoreSIGPIPE(): Fill in sa_mask

Issue #231.
Fix potential segfault in waitForInput()

Since the addition of build-max-log-size, a call to
handleChildOutput() can result in cancellation of a goal.  This
invalidated the "j" iterator in the waitForInput() loop, even though
it was still used afterwards.  Likewise for the maxSilentTime
handling.

Probably fixes #231.  At least it gets rid of the valgrind warnings.
Drop pointless #include
boost::shared_ptr -> std::shared_ptr
Fix nix-shell for derivation with multiple outputs

If derivation declares multiple outputs and first (default) output
if not "out", then "nix-instantiate" calls return path with output
names appended after "!". Than suffix must be stripped before
ant path checks are done.
nix-env: Add support for --delete-generations 15d

It will delete all generations older than the specified number of days.
nix-collect-garbage: Add --delete-older-than option
Add test for readdir builtin
Add readdir primop

This is useful for things like nix-make, and may make nixpkgs's organization cleaner