 
   emitPaths = (paths) ->
     process.stdout.write(JSON.stringify(paths)+'\n')
-  done = ->
+  emitEnd = ->
     process.stdout.write(STOP_CHAR+'\n')
-    process.send(event: 'finished')
 
   options =
     pathToScan: process.env.pathToScan


  START_CHAR = String.fromCharCode(1)
  END_CHAR = String.fromCharCode(4)

  scanTask = makeTask(multiProcessScan)
  searchTask = makeTask(multiProcessSearch)

  searchProcess = fork(searchTask, env)

  searchProcess.stdin.setEncoding = 'utf-8';
  scanProcess.stdout.pipe(split()).on 'data', (data) ->
    if data[0] == STOP_CHAR
      scanFinished = true
      console.log 'Scan done'
      maybeEnd()
    else
      searches++
      searchProcess.stdin.write(data+'\n')

  searchProcess.stderr.pipe(process.stderr)

  searchProcess.stdout.pipe(split()).on 'data', (line) ->
    if line[0] == START_CHAR
      console.log "search start"
    else if line[0] == END_CHAR
      searches--
      console.log "search end #{searches}"
    else if line and line.length
      try
        results = JSON.parse(line)
      catch e
        console.log "AHH", e
      if results
        pathCount++
        resultCount += results.results.length
