anchor.diff:  
     /// Whether the user has scheduled the end of this process by calling either
     /// [shouldExit] or [kill].
  -  var _endScheduled = false;
  -
  -  /// The task that runs immediately before this process is scheduled to end. If
  -  /// the process ends during this task, we treat that as expected.
  -  Task _taskBeforeEnd;
  -
  -  /// Whether the process is expected to terminate at this point.
  -  var _endExpected = false;
  +  bool get _endScheduled => _scheduledExitTask != null;
  +
  +  /// The task where this process is scheduled to exit -- either by waiting to
  +  /// exit ([shouldExit]) or by killing the process ([kill]).
  +  ///
  +  /// It's legal for the process to exit before this task runs. This can happen
  +  /// for example if there's still standard output to read from the process
  +  /// after it exits.
  +  Task _scheduledExitTask;
  +
  +  /// The task during which the process actually exited.
  +  Task _actualExitTask;
   
     /// Schedules a process to start. [executable], [arguments],
     /// [workingDirectory], and [environment] have the same meaning as for
  
positive.code:     // queue where the process will be killed, rather than blocking the tasks
      // queue waiting for the process to exit.
      _process.then((p) => Chain.track(p.exitCode)).then((exitCode) {
        if (_endExpected) {
          exitCodeCompleter.complete(exitCode);
          return;
        }
  
        wrapFuture(pumpEventQueue().then((_) {
          if (currentSchedule.currentTask != _taskBeforeEnd) return null;
          // If we're one task before the end was scheduled, wait for that task
          // to complete and pump the event queue so that _endExpected will be
          // set.
          return _taskBeforeEnd.result.then((_) => pumpEventQueue());
        }).then((_) {
          exitCodeCompleter.complete(exitCode);
  
          if (!_endExpected) {
            fail("Process '$description' ended earlier than scheduled "
                 "with exit code $exitCode.");
          }
        }), "waiting to reach shouldExit() or kill() for process "
            "'$description'");
      });
    }
  
  
negative.code:       var killedPrematurely = false;
        if (!_exitCode.hasValue) {
          killedPrematurely = true;
          _process.value.kill(ProcessSignal.SIGKILL);
          // Ensure that the onException queue waits for the process to actually
          // exit after being killed.
  