From 8dd37885cbb75621dfd42ad53244bf38202ab828 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 3 Mar 2011 10:31:17 +0100 Subject: [PATCH] extending of our test program => using of the system call "execve" --- newlib/examples/tests.c | 4 +++- newlib/src/libgloss/metalsvm/environ.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/newlib/examples/tests.c b/newlib/examples/tests.c index 78603b14..20723195 100644 --- a/newlib/examples/tests.c +++ b/newlib/examples/tests.c @@ -36,8 +36,10 @@ int main(int argc, char** argv) pid = fork(); if (pid == 0) { // child + char* args[] = {"/bin/hello", (char*) 0}; + printf("Hello from child process!\n"); - exit(42); + execve("/bin/hello", args, environ); } else { printf("Hello from parent process! pid = %u\n", pid); wait(&status); diff --git a/newlib/src/libgloss/metalsvm/environ.c b/newlib/src/libgloss/metalsvm/environ.c index 26ff78c6..1dd0e212 100644 --- a/newlib/src/libgloss/metalsvm/environ.c +++ b/newlib/src/libgloss/metalsvm/environ.c @@ -17,5 +17,6 @@ * This file is part of MetalSVM. */ -char *__env[1] = { 0 }; +/* default environment */ +char *__env[] = { "USER=root", "PATH=/bin:/sbin:/usr/bin", "PWD=/", (char *) 0 }; char **environ = __env;