anchor.diff:  
   
   %% @doc Start an OS process and returns.
  -%% The current process will receive the following messages:
  +%% The current process will receive the following messages with the format
  +%% {?MODULE, pid(), Msg}.
  +%%
  +%% The messages that will be received are:
  +%% - {start, OsPid}:    When the process starts, returns the OS PID
  +%% - {data, binary()}:  Data (parsed is defined) returned from stdout/stderr
  +%% - {stop, Reason}:    When the process stops
  +%%
   -spec async(binary()|iolist(), start_opts()) ->
       {ok, pid()} | {error, term()}.
   
  
positive.code: -behaviour(gen_server).
  
  -export([async/2, send_data/2, close/1, sync/2, get_all/0]).
  -export([start_link/2, init/1, terminate/2, code_change/3, handle_call/3,
           handle_cast/2, handle_info/2]).
  
  -type refresh_fun() ::
      fun((Cmd::binary()) -> binary | iolist()).
  
  -type parser_fun() ::
      fun((Buff::binary()) -> more | {ok, Data::binary(), Rest::binary()}).
  
  -type start_opts() :: 
      #{
          timeout => integer(),
          refresh_fun => refresh_fun(),
          parser => lines | parser_fun(),
          stop_time => integer()
      }.
  
  
  
negative.code: 
  
  %% @private
  restart_timer(#state{timeout_time=undefined}=State) ->
      State;
  
  restart_timer(#state{timeout_time=Time, timeout_ref=Ref}=State) ->
      nklib_util:cancel_timer(Ref),
      State#state{timeout_ref=erlang:send_after(Time, self(), timeout)}.
  
  
  %% @private
  send_user_msg(Msg, #state{cmd=Cmd, user_pid=Pid}) ->
      lager:debug("nklib_exec ~s sending msg: ~p", [Cmd, Msg]),
      Pid ! {?MODULE, self(), Msg}.
  
  
  