Exemplo n.º 1
0
 def _exec(self, cmd, env, pwent):
     # close all other file descriptors for child.
     if pwent:
         run_as(pwent)
     if env:
         os.execvpe(cmd[0], cmd, env)
     else:
         os.execvp(cmd[0], cmd)
Exemplo n.º 2
0
 def _exec(self, cmd, env, pwent):
     # close all other file descriptors for child.
     if pwent:
         run_as(pwent)
     if env:
         os.execvpe(cmd[0], cmd, env)
     else:
         os.execvp(cmd[0], cmd)
Exemplo n.º 3
0
 def __init__(self, pwent=None, _pgid=0):
     super().__init__(sys.argv[0])
     pid = os.fork()
     if pid == 0:
         sys.excepthook = sys.__excepthook__  # remove any debugger hook
         if pwent:
             run_as(pwent)
     self.childpid = pid
     self.childpid2 = None  # for compatibility with pipeline
Exemplo n.º 4
0
 def __init__(self, pwent=None, _pgid=0):
     super().__init__(sys.argv[0])
     pid = os.fork()
     if pid == 0:
         sys.excepthook = sys.__excepthook__  # remove any debugger hook
         if pwent:
             run_as(pwent)
     self.childpid = pid
     self.childpid2 = None  # for compatibility with pipeline
Exemplo n.º 5
0
 def run(self):
     reactor = selectors.DefaultSelector()
     sock = self.open()
     reactor.register(sock, selectors.EVENT_READ)
     while True:
         events = reactor.select()
         for key, mask in events:
             conn, addr = key.fileobj.accept()
             conn.set_inheritable(True)
             pid = os.fork()
             if pid == 0:
                 try:
                     if self._pwent is not None:
                         run_as(self._pwent)
                     _handle_request(self._app, conn)
                 finally:
                     conn.close()
                 os._exit(0)
             else:
                 conn.close()
Exemplo n.º 6
0
 def run(self):
     reactor = selectors.DefaultSelector()
     sock = self.open()
     reactor.register(sock, selectors.EVENT_READ)
     while True:
         events = reactor.select()
         for key, mask in events:
             conn, addr = key.fileobj.accept()
             conn.set_inheritable(True)
             pid = os.fork()
             if pid == 0:
                 try:
                     if self._pwent is not None:
                         run_as(self._pwent)
                     _handle_request(self._app, conn)
                 finally:
                     conn.close()
                 os._exit(0)
             else:
                 conn.close()
Exemplo n.º 7
0
            os.setpgid(0, _pgid)
            os.close(0)
            os.close(1)
            os.close(2)
            os.dup2(p2cread, 0)
            os.close(p2cread)
            os.dup2(c2pwrite, 1)
            if merge:
                os.dup2(c2pwrite, 2)
            else:
                os.dup2(c2perr, 2)
                os.close(c2perr)
            os.close(c2pwrite)
            try:
                if pwent:
                    run_as(pwent)
                if env:
                    os.execvpe(cmd[0], cmd, env)
                else:
                    os.execvp(cmd[0], cmd)
            finally:
                os._exit(127)
            # Shouldn't come here
            os._exit(127)
        # parent
        os.close(p2cread)
        os.close(c2pwrite)
        if c2perr:
            os.close(c2perr)

    def isatty(self):
Exemplo n.º 8
0
            os.setpgid(0, _pgid)
            os.close(0)
            os.close(1)
            os.close(2)
            os.dup2(p2cread, 0)
            os.close(p2cread)
            os.dup2(c2pwrite, 1)
            if merge:
                os.dup2(c2pwrite, 2)
            else:
                os.dup2(c2perr, 2)
                os.close(c2perr)
            os.close(c2pwrite)
            try:
                if pwent:
                    run_as(pwent)
                if env:
                    os.execvpe(cmd[0], cmd, env)
                else:
                    os.execvp(cmd[0], cmd)
            finally:
                os._exit(127)
            # Shouldn't come here
            os._exit(127)
        # parent
        os.close(p2cread)
        os.close(c2pwrite)
        if c2perr:
            os.close(c2perr)

    def isatty(self):