|
[php]
def _exec(file, args='', _block=True):
if type(args) is type([]):
args.insert(0, file)
elif type(args) is type(str()):
args = [file, args]
elif type(args) is type(()):
args = list(args)
args.insert(0, file)
else:
return False
pid = os.fork()
if pid < 0: # cannot fork ?
return False
elif pid == 0: # run child code here
os.execvp(file, args)
else: # pid > 0: # run parent code here
if _block:
return os.waitpid(pid, 0)
else:
os.waitpid(pid, os.WNOHANG)
[/php]
请大家帮我看看, 怎么能更完善一些?
写写了! |
|