typo
[AROS.git] / compiler / posixc / execlp.c
blob2766477108fc42d57e898029f93ed17ba2a9b53d
1 /*
2 Copyright © 2008-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 POSIX.1-2008 function execlp().
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 execlp(
22 /* SYNOPSIS */
23 const char *file,
24 const char *arg, ...)
26 /* FUNCTION
27 Executes a file with given name. The search paths for the executed
28 file are paths specified in the PATH environment variable.
30 INPUTS
31 file - Name 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(), execl(), execv(), execvp()
48 INTERNALS
50 ******************************************************************************/
52 va_list args;
53 char *const *argv;
54 char ***environptr = __posixc_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(file, 1, 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 } /* execlp() */