Add stats.h.
Add RPM spec.
Add test case.
Do not link with libpthread.
Do not allow unrelated processes share the same stats file.
Do not access file while doing the output.
Handle file truncates.
On Linux open() and truncate() may return EINTR for regular files.

This happens when some process has done fcntl(F_SETLEASE) on the file and
some non-SA_RESTART signal is delivered to us before that process removes
the lease.

Note that unlike truncate(), ftruncate() is unaffected as open() for write
has been done already.