Factor out checking msg for NULL
Simplify 'if' branch
Replay the event buffer *then* send new messages
Refactor handling of socket/fifo/stdin input
Free the expiration time
Move ownership of the path down