diff options
Diffstat (limited to 'posix/execle.c')
-rw-r--r-- | posix/execle.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/posix/execle.c b/posix/execle.c index dc150a4702..a8a016ee69 100644 --- a/posix/execle.c +++ b/posix/execle.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -22,6 +22,8 @@ #include <stddef.h> #include <string.h> +#include <stackinfo.h> + /* Execute PATH with all arguments after PATH until a NULL pointer, and the argument after that for environment. */ int @@ -34,7 +36,7 @@ execle (const char *path, const char *arg, ...) va_list args; argv[0] = arg; - va_start(args, arg); + va_start (args, arg); i = 0; while (argv[i++] != NULL) { @@ -42,16 +44,21 @@ execle (const char *path, const char *arg, ...) { const char **nptr = alloca ((argv_max *= 2) * sizeof (const char *)); +#ifndef _STACK_GROWS_UP if ((char *) nptr + argv_max == (char *) argv) { /* Stack grows down. */ argv = (const char **) memcpy (nptr, argv, i); argv_max += i; } - else if ((char *) argv + i == (char *) nptr) + else +#endif +#ifndef _STACK_GROWS_DOWN + if ((char *) argv + i == (char *) nptr) /* Stack grows up. */ argv_max += i; else +#endif /* We have a hole in the stack. */ argv = (const char **) memcpy (nptr, argv, i); } @@ -59,8 +66,8 @@ execle (const char *path, const char *arg, ...) argv[i] = va_arg (args, const char *); } - envp = va_arg(args, const char *const *); - va_end(args); + envp = va_arg (args, const char *const *); + va_end (args); - return __execve(path, (char *const *) argv, (char *const *) envp); + return __execve (path, (char *const *) argv, (char *const *) envp); } |