 
   START_CHAR = String.fromCharCode(1)
   END_CHAR = String.fromCharCode(4)
+  STOP_CHAR = String.fromCharCode(0)
 
   scanTask = makeTask(multiProcessScan)
   searchTask = makeTask(multiProcessSearch)

  searchProcess = fork(searchTask, env)

  searchProcess.stdin.setEncoding = 'utf-8';
  scanProcess.stdout.on 'data', (data) ->
    searchProcess.stdin.write(data)

  searchProcess.stderr.pipe(process.stderr)

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


  scanner.on 'finished-scanning', ->
    emitPaths(paths) if paths.length
    emitEnd()

  scanner.scan()

