日期:2014-05-16  浏览次数:20795 次

execl执行shell命令问题
我编写ucLinux应用程序时遇到一个问题
ucLinux使用函数execl来执行shell命令时提示出错调用方式如:
if (execl("/bin/sh","sh","-c","ls /usr/bin",(char*)0) == -1)
{
 printf("执行Linux命令:%s 失败,原因:%s : %d\n","ls /usr/bin",strerror(errno),errno);  
}
execl运行成功,但是执行命令ls /usr/bin失败
Linux内核提示
ls: page allocation failure. order:7, mode:0x40d0
Mem-info:
DMA per-cpu:
CPU 0: Hot: hi: 0, btch: 1 usd: 0 Cold: hi: 0, btch: 1 usd: 0
Active:126 inactive:129 dirty:0 writeback:0 unstable:0
 free:254 slab:953 mapped:0 pagetables:0 bounce:0
DMA free:1016kB min:360kB low:448kB high:540kB active:504kB inactive:516kB present:8128kB pages_scanned:0 all_unreclaimable? no
lowmem_reserve[]: 0 0
DMA: 12*4kB 7*8kB 9*16kB 2*32kB 1*64kB 1*128kB 0*256kB 1*512kB 0*1024kB 0*2048kB 0*4096kB = 1016kB
Free swap: 0kB
2048 pages of RAM
273 free pages
540 reserved pages
953 slab pages
9 pages shared
0 pages swap cached
Allocation of length 329063 from process 41 failed
DMA per-cpu:
CPU 0: Hot: hi: 0, btch: 1 usd: 0 Cold: hi: 0, btch: 1 usd: 0
Active:126 inactive:129 dirty:0 writeback:0 unstable:0
 free:254 slab:953 mapped:0 pagetables:0 bounce:0
DMA free:1016kB min:360kB low:448kB high:540kB active:504kB inactive:516kB present:8128kB pages_scanned:0 all_unreclaimable? no
lowmem_reserve[]: 0 0
DMA: 12*4kB 7*8kB 9*16kB 2*32kB 1*64kB 1*128kB 0*256kB 1*512kB 0*1024kB 0*2048kB 0*4096kB = 1016kB
Unable to allocate RAM for process text/data, errno 12
Unhandled fault: vector exception (0x000) at 0x00000000
SEGV

------解决方案--------------------
程序应该没问题
你手工执行ls /usr/bin是否也有同样问题?
------解决方案--------------------
不懂,手工能执行,那内核应该也是好的啊
会不会开发库有问题..
------解决方案--------------------

喔。LZ是对的。呵呵。抱歉。
------解决方案--------------------
我觉得是开发库的问题
------解决方案--------------------

LZ要不要用ldd先检查一下链接的库?

呵呵。我对这个帖子还是有点在意,想知道结果。
------解决方案--------------------
开发库是什么