beam: more optional debugging hooks for FD tracking
beam: fix FD leaks in SendPipe
[WIP] beam/examples/beamsh: catch introspection calls from jobs for proper nesting
beam/examples/beamsh: basic exec command
beam/examples/beamsh: better debugging messages
beam/examples/beamsh: basic implementation of the pipeline design, with static handlers for now. It works!
beam/data: convenience Message.Pretty() function
beam/examples/beamsh: prettier 'trace' command
beam/data: prettier Message.Pretty()
beam/examples/beamsh: prettier devnull
beam/examples/beamsh: exec and listen commands
beam/examples/beamsh: new 'connect' command
beam/examples/beamsh: utility function 'fileToConn'
beam: Make extracted Fds CloseOnExec

Grab forklock to make sure no forks accidentally inherit the new fds
before they are made CLOEXEC There is a slight race condition between
ReadMsgUnix returns and when we grap the lock, so this is not
perfect. Unfortunately There is no way to pass MSG_CMSG_CLOEXEC to
recvmsg() nor any way to implement non-blocking i/o in go, so this is
hard to fix.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
beam: Add more tests to unix_test.go

All these are failing, and indicate things that need to be cleaned
up.

Note: TestUSocketPair isn't failing per-se, but it exposes a double
close problem which needs to be fixed.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
beam: Fix double-close of fds in FdConn

We pass an *os.File instead of an fd int into FdConn, because
otherwise we have to call os.NewFile on the passed in Fd, which
is problematic as that sets a finalizer for that object which closes
the fd. This means the fd passed in will be closed during GC, which
is not expected.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
beam: Fix double close of fds in SendUnix

Instead of calling syscall.Close() on the fds in sendUnix() we call
Close() on the *os.File in Send(). Otherwise the fd will be closed, but
the *os.File will continue to live, and when it is finalized the
fd will be closed (which by then may be reused and can be anything).

This also adds a note to Send() the the file is closed.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
beam: Make fd passing limit more robust

We pass a maxFds to receiveUnix, which lets us limit the oob data size.
This means the kernel will close any extra fds for us before creating
fds for the process. This protects us against filling up the process
file descriptor table.

We also pass extractFds the max and close any extra, because the size
limit is not perfect due to padding/alignment. For instance, on 64bit
arches the alignment of cmsgdata is 8, but that can fit two fds, so we
can't limit to 1 fd that way.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
beam: Add simple framing system

This is needed for Send/Recieve to correctly handle borders between
the messages.

Also, in order for this to work i need to store recieved file
descriptors as they may be read before the correspondinf message.
So, we add a beam.BeamConn type to store this in and make the
operations methods on that instead.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)