anchor.diff:          {stop, _, State2} -> State2
       end.
   
  +terminate(Reason, #state{port = P} = _State) when not is_port(P) ->
  +    ?log_debug("doing nothing in terminate(~p) because port is not active", [Reason]),
  +    ok;
   terminate(shutdown, #state{send_eol = true, port = Port, name = Name} = State) ->
       ShutdownCmd = misc:get_env_default(ns_babysitter, port_shutdown_command, "shutdown"),
       ?log_debug("Sending ~s to port ~p", [ShutdownCmd, Name]),
  
positive.code: init(Fun) ->
      {Name, _Cmd, _Args, Opts} = Params = Fun(),
      process_flag(trap_exit, true), % Make sure terminate gets called
      {SendEOL, Params2} =
          case proplists:get_value(port_server_send_eol, Opts) of
              undefined ->
                  {false, Params};
              V ->
                  {V, setelement(4, Params, proplists:delete(port_server_send_eol, Opts))}
          end,
      Port = open_port(Params2),
      {ok, #state{port = Port, name = Name, send_eol = SendEOL,
                  messages = ringbuffer:new(?NUM_MESSAGES)}}.
  
  handle_info({send_to_port, Msg}, State) ->
      ?log_debug("Sending the following to port: ~p", [Msg]),
      port_command(State#state.port, Msg),
  
negative.code: -include_lib("eunit/include/eunit.hrl").
  
  %% Server state
  -record(state, {port :: port() | {inactive, tuple()},
                  name :: term(),
                  messages,
                  log_tref :: timer:tref(),
  