从linux中的c ++调用时,系统返回错误127 [英] system is returning error 127 when called from c++ in linux
问题描述
命令" am start -n packagename/.activityname "必须在adb shell中运行,并包含在C ++程序中
The command "am start -n packagename/.activityname" has to be run in adb shell and is to be included in C++ program
我在C ++程序中添加了行 system("am start -n packagename/.activityname"),并且该程序在adb shell中运行时, 系统命令返回错误代码127,而shell命令未运行
I added the line system("am start -n packagename/.activityname") in my C++ program and when the program is run in adb shell, the system command is returning error code 127 and the shell command is not running
使用的编译器: arm-linux-none-gnueabi-g ++
在我使用g ++编译器时可以正常工作
Its working when i used the g++ compiler
编译器或路径有问题吗?
Is the problem with the compiler or with the path?
推荐答案
system()无法在具有/bin/sh是bash版本2,因为bash 2在启动linux.die.net/man/3/system上放弃了特权
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 linux.die.net/man/3/system
我使用的不是
其中test.sh具有 am start -n packagename/.activityname ,并且可以正常工作
where test.sh has am start -n packagename/.activityname and it works
这篇关于从linux中的c ++调用时,系统返回错误127的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!