Synchronize forkpty master and child to avoid hang on AIX with fast exiting
child and output left in the queue, from J Raynor.