tools/toollib: remove from main Makefile.in
[AROS.git] / compiler / posixc / execl.c
blobdf9fe62e8fc02528c263e9098764ea398de765e9
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 POSIX.1-2008 function execl().
6 */
8 #include <aros/debug.h>
9 #include <errno.h>
10 #include <assert.h>
11 #include <stdlib.h>
13 #include "__exec.h"
15 /*****************************************************************************
17 NAME */
18 #include <unistd.h>
20 int execl(
22 /* SYNOPSIS */
23 const char *path,
24 const char *arg, ...)
26 /* FUNCTION
27 Executes a file located in given path with specified arguments.
29 INPUTS
30 path - Pathname of the file to execute.
31 arg - First argument passed to the executed file.
32 ... - Other arguments passed to the executed file.
34 RESULT
35 Returns -1 and sets errno appropriately in case of error, otherwise
36 doesn't return.
38 NOTES
40 EXAMPLE
42 BUGS
44 SEE ALSO
45 execve(), execlp(), execv(), execvp()
47 INTERNALS
49 ******************************************************************************/
51 va_list args;
52 char *const *argv;
53 char ***environptr = __posixc_get_environptr();
54 char **environ = (environptr != NULL) ? *environptr : NULL;
56 va_start(args, arg);
58 if(!(argv = __exec_valist2array(arg, args)))
60 errno = ENOMEM;
61 return -1;
64 va_end(args);
66 APTR id = __exec_prepare(path, 0, argv, environ);
67 __exec_cleanup_array();
68 if (!id)
69 return -1;
71 __exec_do(id);
73 assert(0); /* Should not be reached */
74 return -1;
75 } /* execl() */