Removed double NAME entry.
[AROS.git] / compiler / clib / execlp.c
blob4222e06d932fcc11d4097184ea18c80a76b8302f
1 /*
2 Copyright © 2008-2009, The AROS Development Team. All rights reserved.
3 $Id$
5 POSIX function execlp().
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 execlp(
23 /* SYNOPSIS */
24 const char *file,
25 const char *arg, ...)
27 /* FUNCTION
28 Executes a file with given name. The search paths for the executed
29 file are paths specified in the PATH environment variable.
31 INPUTS
32 file - Name of the file to execute.
33 arg - First argument passed to the executed file.
34 ... - Other arguments passed to the executed file.
36 RESULT
37 Returns -1 and sets errno appropriately in case of error, otherwise
38 doesn't return.
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
47 execve(), execl(), execv(), execvp()
49 INTERNALS
51 ******************************************************************************/
53 va_list args;
54 char *const *argv;
55 char ***environptr = __arosc_get_environptr();
56 char **environ = (environptr != NULL) ? *environptr : NULL;
58 va_start(args, arg);
60 if(!(argv = __exec_valist2array(arg, args)))
62 errno = ENOMEM;
63 return -1;
66 va_end(args);
68 APTR id = __exec_prepare(file, 1, argv, environ);
69 __exec_cleanup_array();
70 if (!id)
71 return -1;
73 __exec_do(id);
75 assert(0); /* Should not be reached */
76 return -1;
77 } /* execlp() */