示例#1
0
 def start_child(i):
     #log.info( "Starting http connection process process, taskid %s", i )
     pid = os.fork()
     if pid == 0:
         # child process
         h.reseed_random()
         global _task_id
         _task_id = i
         return i
     else:
         children[pid] = i
         return None
示例#2
0
    def fork_and_monitor( self, args ):
        """Fork a child process with same command line arguments except the
        ``-m`` switch. Monitor and reload the child process until normal
        exit."""
        while True :
            self.pa.logdebug( "Forking monitor ..." )
            pid = os.fork()
            if pid == 0 :   # child process
                cmdargs = sys.argv[:]
                cmdargs.remove( '-m' )
                cmdargs.append( os.environ )
                h.reseed_random()
                os.execlpe( sys.argv[0], *cmdargs )

            else :          # parent 
                try :
                    pid, status = os.wait()
                    if status & 0xFF00 != 0x300 :
                        sys.exit( status )
                except KeyboardInterrupt :
                    sys.exit(0)
示例#3
0
    def fork_and_monitor(self, args):
        """Fork a child process with same command line arguments except the
        ``-m`` switch. Monitor and reload the child process until normal
        exit."""
        while True:
            self.pa.logdebug("Forking monitor ...")
            pid = os.fork()
            if pid == 0:  # child process
                cmdargs = sys.argv[:]
                cmdargs.remove('-m')
                cmdargs.append(os.environ)
                h.reseed_random()
                os.execlpe(sys.argv[0], *cmdargs)

            else:  # parent
                try:
                    pid, status = os.wait()
                    if status & 0xFF00 != 0x300:
                        sys.exit(status)
                except KeyboardInterrupt:
                    sys.exit(0)