• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Revisionaaa03057118b3225fcd72f0b3039f76b1fd80398 (tree)
Zeit2015-12-22 12:21:35
AutorMagnus Malmborn <magnus.malmborn@sony...>
CommiterChih-Wei Huang

Log Message

Adding an 'exec' implementation to init

This is useful for running programs synchronously
during startup.

Change-Id: I0212fad22613124dd13b4f20b86d0dcc6cb59b6e

Ändern Zusammenfassung

Diff

--- a/init/builtins.c
+++ b/init/builtins.c
@@ -27,6 +27,7 @@
2727 #include <linux/if.h>
2828 #include <arpa/inet.h>
2929 #include <stdlib.h>
30+#include <sys/wait.h>
3031 #include <sys/mount.h>
3132 #include <sys/resource.h>
3233 #include <sys/wait.h>
@@ -256,7 +257,36 @@ int do_enable(int nargs, char **args)
256257
257258 int do_exec(int nargs, char **args)
258259 {
259- return -1;
260+ pid_t pid;
261+ int status, i, prop_fd, prop_size, ret;
262+ char *par[nargs], env_property[64], *env[2];
263+
264+ for (i = 0; i < (nargs - 1); i++) {
265+ par[i] = args[i + 1];
266+ }
267+ par[i] = NULL;
268+
269+ pid = fork();
270+ if (pid == 0) {
271+ /* Enable system properties */
272+ get_property_workspace(&prop_fd, &prop_size);
273+ memset(env_property, 0, sizeof(env_property));
274+ sprintf(env_property, "ANDROID_PROPERTY_WORKSPACE=%d,%d",
275+ dup(prop_fd), prop_size);
276+ env[0] = env_property;
277+ env[1] = NULL;
278+
279+ ret = execve(par[0], par, env);
280+ ERROR("execve %s (ret = %d, errno = %d)\n", par[0], ret, errno);
281+ _exit(127);
282+ } else if (pid > 0) {
283+ do {
284+ ret = waitpid(pid, &status, 0);
285+ } while ((ret < 0) && (errno == EINTR));
286+ } else {
287+ ERROR("fork error\n");
288+ }
289+ return 0;
260290 }
261291
262292 int do_export(int nargs, char **args)