def _init_multiprocessing():
 global _buffer
 global _n
 if _multiprocessing:
  print('[i] preparing capture buffer...')
  try:
   _buffer = mmap.mmap((-1), config.CAPTURE_BUFFER)
   _ = ('\x00' * MMAP_ZFILL_CHUNK_LENGTH)
   for i in xrange((config.CAPTURE_BUFFER / MMAP_ZFILL_CHUNK_LENGTH)):
    _buffer.write(_)
   _buffer.seek(0)
  except KeyboardInterrupt:
   raise
  except:
   exit("[!] unable to allocate network capture buffer. Please adjust value of 'CAPTURE_BUFFER'")
  print(('[i] creating %d more processes (out of total %d)' % ((config.PROCESS_COUNT - 1), config.PROCESS_COUNT)))
  _n = _multiprocessing.Value('L', lock=False)
  for i in xrange((config.PROCESS_COUNT - 1)):
   process = _multiprocessing.Process(target=worker, name=str(i), args=(_buffer, _n, i, (config.PROCESS_COUNT - 1), _process_packet))
   process.daemon = True
   process.start()

def _init_multiprocessing ( ) : global _buffer global _n if _multiprocessing : print ( '[i] preparing capture buffer...' ) try : _buffer = mmap . mmap ( ( - 1 ) , config . CAPTURE_BUFFER ) _ = ( '\x00' * MMAP_ZFILL_CHUNK_LENGTH ) for i in xrange ( ( config . CAPTURE_BUFFER / MMAP_ZFILL_CHUNK_LENGTH ) ) : _buffer . write ( _ ) _buffer . seek ( 0 ) except KeyboardInterrupt : raise except : exit ( "[!] unable to allocate network capture buffer. Please adjust value of 'CAPTURE_BUFFER'" ) print ( ( '[i] creating %d more processes (out of total %d)' % ( ( config . PROCESS_COUNT - 1 ) , config . PROCESS_COUNT ) ) ) _n = _multiprocessing . Value ( 'L' , lock = False ) for i in xrange ( ( config . PROCESS_COUNT - 1 ) ) : process = _multiprocessing . Process ( target = worker , name = str ( i ) , args = ( _buffer , _n , i , ( config . PROCESS_COUNT - 1 ) , _process_packet ) ) process . daemon = True process . start ( )
inits worker processes used in multiprocessing mode .