compiler/clib: Remove usage of acb_environptr field outside __arosc_environ.c
[AROS.git] / compiler / clib / execl.c
blob0ea2b2cfe550a174fa394b86adb56c3da55014cf
1 /*
2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
3 $Id$
5 POSIX function execl().
6 */
8 #include <aros/debug.h>
9 #include <errno.h>
10 #include <assert.h>
11 #include <stdlib.h>
13 #include "__arosc_privdata.h"
14 #include "__exec.h"
16 /*****************************************************************************
18 NAME */
19 #include <unistd.h>
21 int execl(
23 /* SYNOPSIS */
24 const char *path,
25 const char *arg, ...)
27 /* FUNCTION
28 Executes a file located in given path with specified arguments.
30 INPUTS
31 path - Pathname of the file to execute.
32 arg - First argument passed to the executed file.
33 ... - Other arguments passed to the executed file.
35 RESULT
36 Returns -1 and sets errno appropriately in case of error, otherwise
37 doesn't return.
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
46 execve(), execlp(), execv(), execvp()
48 INTERNALS
50 ******************************************************************************/
52 va_list args;
53 char *const *argv;
54 char ***environptr = __arosc_get_environptr();
55 char **environ = (environptr != NULL) ? *environptr : NULL;
57 va_start(args, arg);
59 if(!(argv = __exec_valist2array(arg, args)))
61 errno = ENOMEM;
62 return -1;
65 va_end(args);
67 APTR id = __exec_prepare(path, 0, argv, environ);
68 __exec_cleanup_array();
69 if (!id)
70 return -1;
72 __exec_do(id);
74 assert(0); /* Should not be reached */
75 return -1;
76 } /* execl() */