how to run shell commands in ndk

1,384 views
Skip to first unread message

neeraja

unread,
Sep 8, 2010, 6:29:30 AM9/8/10
to android-ndk
Hi,
main()
{
int i = execv("su"); ;
}

returns -1, file not found.
I want to run my daemon from android ndk.

David Turner

unread,
Sep 8, 2010, 9:23:36 AM9/8/10
to andro...@googlegroups.com
try to specify the path to the executable (e.g. /system/bin/su). Are you sure there is an "su" executable on your system anyway.

Keep in mind that forking and execing from application processes is not supported by the system. What this means is that
the system might decide to abruptly kill any of such processes if it finds one. The feature might even be removed in the future
(e.g. would fail with a permission error).


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Dianne Hackborn

unread,
Sep 8, 2010, 12:48:28 PM9/8/10
to andro...@googlegroups.com
Also, no shell commands are part of the SDK/NDK -- you can't count on them existing across platforms or devices or behaving the same way.
--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Reply all
Reply to author
Forward
0 new messages