def g(): l = rffi.liststr2charpp(["a", "b", "c"]) try: set_z(l) return rffi.charp2str(get_z()[2]) finally: rffi.free_charpp(l)
def execv_lltypeimpl(path, args): l_path = rffi.str2charp(path) l_args = rffi.liststr2charpp(args) os_execv(l_path, l_args) rffi.free_charpp(l_args) rffi.free_charp(l_path) raise OSError(rffi.c_errno, "execv failed")
def Sys_SetArgv(self,argv): impl = self.lib.getpointer("PySys_SetArgv",[libffi.ffi_type_sint,libffi.ffi_type_pointer],libffi.ffi_type_void) impl.push_arg(len(argv)) buf = rffi.liststr2charpp(argv) impl.push_arg(rffi.cast(rffi.VOIDP,buf)) impl.call(lltype.Void) rffi.free_charpp(buf)
def Sys_SetArgv(self,argv): impl = self.lib.getpointer("PySys_SetArgv",[clibffi.ffi_type_sint,clibffi.ffi_type_pointer],clibffi.ffi_type_void) impl.push_arg(len(argv)) buf = rffi.liststr2charpp(argv) impl.push_arg(rffi.cast(rffi.VOIDP,buf)) impl.call(lltype.Void) rffi.free_charpp(buf)
def spawnv_llimpl(mode, path, args): mode = rffi.cast(rffi.INT, mode) l_args = rffi.liststr2charpp(args) childpid = os_spawnv(mode, path, l_args) rffi.free_charpp(l_args) if childpid == -1: raise OSError(rposix.get_errno(), "os_spawnv failed") return rffi.cast(lltype.Signed, childpid)
def execve_llimpl(path, args, env): # XXX Check path, args, env for \0 and raise TypeErrors as # appropriate envstrs = [] for item in env.iteritems(): envstrs.append("%s=%s" % item) l_args = rffi.liststr2charpp(args) l_env = rffi.liststr2charpp(envstrs) os_execve(path, l_args, l_env) # XXX untested rffi.free_charpp(l_env) rffi.free_charpp(l_args) raise OSError(rposix.get_errno(), "execve failed")
def execv_llimpl(path, args): l_args = rffi.liststr2charpp(args) os_execv(path, l_args) rffi.free_charpp(l_args) raise OSError(rposix.get_errno(), "execv failed")