write: return the number of bytes written

write(3) may return success after writing less than the full buffer
supplied in the argument. From the Linux write(2) man page:

    The  number  of bytes written may be less than count if, for example,
    there is insufficient space on the underlying physical medium, or the
    RLIMIT_FSIZE resource limit is encountered (see setrlimit(2)), or the
    call was interrupted by a signal handler after  having  written  less
    than count bytes.  (See also pipe(7).)
Account for the length of the message header

Since there may be multiple message headers, a read may result in a
valid packet that the next process in the fork chain rejects as too
large.

Calculate the message buffer size for the read based on the length of
the fork chain.