Fix an issue where messages may not be processed by PhutilConsoleServer after the client exits
Summary:
When we call update(), it may move messages into the read() buffer but we won't process them right now. Process messages after update().
Also improve the correctness of the flush() implementation.
See D2841.
Test Plan: Ran test script with 4-second linter child, got 4 messages on stdout.
Reviewers: vrana
Reviewed By: vrana
CC: aran
Differential Revision: https://secure.phabricator.com/D3152