         console.log "[PROCESSES][#{name}]it's time you die process:#{name}" if verbose
         @kill name
       ,die.after
-
 
     @child.on 'exit', ()=>
       console.log "[PROCESSES][#{name}] did exit." if verbose

      stderr : process.stderr
      onExit  : callback

  run: (options,callback) ->
    {name,restartTimeout,verbose} = options

    options.name            ?= Date.now()
    options.restartTimeout ?= 1000
    options.verbose         ?= no

    if options.kontrol?.enabled

catch e
  # do nothing, probably dir is already there.

################################
### HANDLE SIGNALS and KILLS ###
################################

# when doing ctrl+c 
process.on 'SIGINT', =>
  console.log "\nkilled via ctrl+c. this should not happen"
  process.exit(0)

# guaranteed death.
process.on 'SIGTERM', =>
  console.log "going down"
  process.exit(0)

class Processes extends EventEmitter
  constructor:(options={})->
    {main}         = options
    @list          = {}
    @child         = null
    @workerProcess = {}
    @childProcessesContainerDir = __dirname+"/.tmp"
    if main
