#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello\n");
system("echo nikhil");
printf("Hello\n");
getchar();
return 0;
}
当使用arm-none-linux-gnueabi-g++编译此代码时,系统调用将被跳过,除system("echo nikhil")之外的所有其他指令都会被执行
为什么会发生这种情况以及如何避免该问题?
最佳答案
system() will not, in fact, work properly from programs with set-user-ID or set-group-ID privileges on systems on which /bin/sh is bash version 2, since bash 2 drops privileges on startup... http://linux.die.net/man/3/system
您可以尝试使用Exec命令 http://linux.die.net/man/3/exec
关于c++ - 使用arm-none-linux-gnueabi-g++编译时不执行system(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24367623/