       # @workerProcess[name].stopReporter() #TODO think about it
       @kill name
 
-  populateChildObject: (options, @child) ->
+  populateChildObject: (options, child) ->
+
     { name, onMessage, modulePath, args, restart, restartTimeout, cmd, log,
       onExit, stdout, stderr, verbose, die } = options
     onExit ?= ->
     console.log "[PROCESSES][#{name}] started the process: #{name} with pid: #{@child.pid}"  if verbose
-    @createPidFile @child.pid, name
+    @createPidFile child.pid, name
 
     childObj =
       name    : name
-      process : @child
-      pid     : @child.pid
+      process : child
+      pid     : child.pid
       verbose : verbose
+
+    workerProc = @workerProcess[name]
+
 
     if cmd
       childObj.cmd = cmd

        console.log "[PROCESSES][#{name}]it's time you die process:#{name}"  if verbose
        @kill name

    @child.on 'exit', =>
      console.log "[PROCESSES][#{name}] observing a process exiting", @child.pid
      console.log "[PROCESSES][#{name}] did exit."  if verbose
      @emit "exit", @child.pid, name
      delete @list[name]
      if options.kontrol?.enabled
        @workerProcess[name].stopReporter "ack"
        @workerProcess[name].stopReporter "add"
        @workerProcess[name].connection.end()
        delete @workerProcess[name]

    @child.on 'close', =>
      console.log "[PROCESSES][#{name}] did close."  if verbose
      @emit "close", @child.pid, name
      onExit @child.pid, name
      if @disableRestart is yes
        console.log "[PROCESSES][#{name}] restart is disabled because of force mode."  if verbose
        @disableRestart = no

try
  fs.mkdirSync __dirname+"/.tmp/"
catch e

flipped = (fn) -> -> fn.apply this, [ arguments... ].reverse()

