首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

fork新建的过程里面system函数运行的shell命令不能运行

2013-08-04 
fork新建的进程里面system函数运行的shell命令不能运行fork新建的进程里面system函数运行的shell命令不能

fork新建的进程里面system函数运行的shell命令不能运行
fork新建的进程里面system函数运行的shell命令不能运行?
vfork也不行,那里出问题了啊,


运行以后显示
run shell script fail, script exit code: 127


是没有权限,还是咋?




status = system("/bin/ls");   //加路径不加路径都不行
    
    if (-1 == status)  
    {  
        printf("system error!");  
    }  
    else  
    {  
        printf("exit status value = [0x%x]\n", status);  
        
        if (WIFEXITED(status))  
        {  
            if (0 == WEXITSTATUS(status))  
            {  
                printf("run shell script successfully.\n");  
            }  
            else  
            {  
                printf("run shell script fail, script exit code: %d\n", WEXITSTATUS(status));  
            }  
        }  
        else  
        {  
            printf("exit status = [%d]\n", WEXITSTATUS(status));  
        }  
    }  

------解决方案--------------------


完整的代码贴出来看看?
[解决办法]
waitpid应该放到父进程的代码里吧,子进程运行后不exit吗?
[解决办法]
你直接敲下命令
/bin/sh -c /bin/ls
会ok么?

热点排行