LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1161|回复: 3

linux基础编程的一个问题

[复制链接]
发表于 2008-2-20 10:35:55 | 显示全部楼层 |阅读模式
[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]

请大家帮我看看, 怎么能更完善一些?
写写了!
发表于 2008-2-20 12:20:44 | 显示全部楼层
冒昧的问一句, 这是什么语言? 从语法, 格式, 大小写来看有点像 basic, 不过注释比较奇怪
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-2-20 13:49:45 | 显示全部楼层
传说中的Python

我想把这个函数写得再好些
回复 支持 反对

使用道具 举报

发表于 2008-2-25 22:26:07 | 显示全部楼层
写得不错,可以了。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表