Example #1
0
def main(args):
    if len(args) == 0:
        print __doc__
        return 1
    cwd_path = os.getcwd()
    proc = plash.process.ProcessSpec()
    proc.cmd = args[0]
    proc.args = args[1:]
    proc.env = os.environ.copy()
    root_dir = plash.env.get_root_dir()
    proc.caps["conn_maker"] = proc.conn_maker
    proc.caps["fs_op"] = FsOpWrapper(plash.namespace.make_fs_op(root_dir))
    proc.caps["fs_op"].fsop_chdir(cwd_path)
    for fd in (0, 1, 2):
        proc.fds[fd] = plash_core.wrap_fd(os.dup(fd))
    pid = proc.spawn()
    plash.mainloop.run_server()
    pid2, status = os.wait()
    if os.WIFEXITED(status):
        return os.WEXITSTATUS(status)
    elif os.WIFSIGNALED(status):
        sig = os.WTERMSIG(status)
        sys.stderr.write("process killed by signal %i (%s)\n" %
                         (sig, signal_names.get(sig, "unknown")))
    return 127
Example #2
0
 def test_freeing_last_reference(self):
     sock_pair = socket.socketpair()
     # Junk data should not be read because the connection is
     # closed down first.
     sock_pair[1].send("junk data")
     sock_pair[1].close()
     plash_core.cap_make_connection.make_conn2(
         plash_core.wrap_fd(sock_pair[0].fileno()), 1, [])
     # "may_block=False" argument to iteration() method not supported.
     # Adding an idle callback is a workaround.
     def idle_callback():
         return False # remove callback
     gobject.idle_add(idle_callback)
     gobject.main_context_default().iteration()
Example #3
0
def main(args):
    if len(args) == 0:
        print __doc__
        return 1
    cwd_path = os.getcwd()
    proc = Process()
    proc.cmd = args[0]
    proc.args = args[1:]
    proc.env = os.environ.copy()
    root_dir = plash.env.get_root_dir()
    proc.caps["conn_maker"] = proc.conn_maker
    proc.caps["fs_op"] = plash.namespace.make_fs_op(root_dir)
    proc.caps["fs_op"].fsop_chdir(cwd_path)
    for fd in (0, 1, 2):
        proc.fds[fd] = plash_core.wrap_fd(os.dup(fd))
    pid = proc.spawn()
    plash.mainloop.run_server()
    pid2, status = os.wait()
    if os.WIFEXITED(status):
        return os.WEXITSTATUS(status)
    else:
        return 127
Example #4
0
 def log_to_file(self, log_filename):
     fd = plash_core.wrap_fd(
         os.open(log_filename, os.O_WRONLY | os.O_CREAT | os.O_TRUNC))
     self.proc.logger = ns.make_log_from_fd(fd)
Example #5
0
 def enable_logging(self, args):
     fd = plash_core.wrap_fd(os.dup(2))
     self.proc.logger = ns.make_log_from_fd(fd)
Example #6
0
 def add_fd(self, arg):
     fd = int(arg)
     self.proc.fds[fd] = plash_core.wrap_fd(os.dup(fd))
Example #7
0
 def test2(self):
     dir_obj = plash.env.get_root_dir()
     fd = os.open("/dev/null", os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
     log = plash.namespace.make_log_from_fd(plash_core.wrap_fd(fd))
     plash.namespace.make_fs_op(dir_obj, log)