'use strict';

process.stdin.pipe(require('fs').createWriteStream(__dirname + '/output.txt'));
process.stdout.write('output written');
process.stderr.write('error log exists');

setTimeout(function () {
  process.exit(13);
}, 500);
'use strict';

process.stdin.pipe(require('fs').createWriteStream(__dirname + '/output.txt')).on('close', function () {
  setTimeout(function () {
    process.exit(13);
  }, 500);
});
process.stdout.write('output written');
process.stderr.write('error log exists');

Remove race condition in tests
Remove race condition in tests
