嵌入式爱好者

查看: 5392|回复: 1

关于-sh: ./popen: not found问题

[复制链接]

0

主题

0

帖子

3

积分

扫一扫,手机访问本帖
发表于 2011-5-14 22:29:01 | 显示全部楼层 |阅读模式
以下是源码:

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

main()
{
        FILE * fd;
        char *cmd={"ps"};
        char buf[1000];
        buf[1000]='\0';

        if((fd=popen(cmd,"r"))==0)        {printf("popen error");exit;}

        while((fgets(buf,1000,fd))!=NULL)
                printf("%s",buf);
        pclose(fd);
}

内核使用2.6.12,使用4.4.3编译内核和一上源码,使用arm-linux-gcc -o popen popen.c编译后chmod +x popen增加权限后运行提示-sh: ./popen: not found
使用arm-linux-gcc -static -o popen popen.c编译后chmod +x popen增加权限后运行提示Segmentation fault~~
怎么解决~~求解~~~
Ps:以上代码在电脑上gcc编译后运行正常~~
回复

使用道具 举报

0

主题

0

帖子

3

积分

 楼主| 发表于 2011-5-14 22:41:50 | 显示全部楼层
用3.4.1的是没有任何提示跳过~~
# ./popen         
#
#
#
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2024-10-6 19:25

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

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