Ejemplo n.º 1
0
    def _fork_one(self, f):

        # create a pipe to communicate with the child process
        pr, pw = os.pipe()

        # set pr to be non-blocking
        fcntl.fcntl(pr, fcntl.F_SETFL, os.O_NONBLOCK)

        parentpid = os.getpid()
        rc = 1

        try:

            # create child process
            pid = os.fork()

            if pid == 0:
                # child process:
                os.close(pr)
                pyabc.close_on_fork(pw)

                rc = self.child(pw, f)
                os._exit(rc)
            else:
                # parent process:
                os.close(pw)
                return (pid, pr)

        finally:
            if os.getpid() != parentpid:
                os._exit(rc)
Ejemplo n.º 2
0
    def fork_one(self, f):
        
        # create a pipe to communicate with the child process
        pr,pw = os.pipe()
        
        parentpid = os.getpid()
        rc = 1
        
        try:

            # create child process
            pid = os.fork()
    
            if pid == 0:
                # child process:
                os.close(pr)
                pyabc.close_on_fork(pw)
                
                rc = self.child( pw, f)
                os._exit(rc)
            else:
                # parent process:
                os.close(pw)
                return (pid, pr)
                
        finally:
            if os.getpid() != parentpid:
                os._exit(rc)
    def fork_one(self, f):

        # create a pipe to communicate with the child process
        pr, pw = os.pipe()

        # set pr to be non-blocking
        fcntl.fcntl(pr, fcntl.F_SETFL, os.O_NONBLOCK)

        parentpid = os.getpid()
        rc = 1

        try:

            # create child process
            pid = os.fork()

            if pid == 0:
                # child process:
                os.close(pr)
                pyabc.close_on_fork(pw)

                rc = self.child(pw, f)
                os._exit(rc)
            else:
                # parent process:
                os.close(pw)
                return (pid, pr)

        finally:
            if os.getpid() != parentpid:
                os._exit(rc)