Added execvpe().
* This closes #12114 again; while not POSIX, it's just a line away. * Removed exect() from the header -- not sure where this came from. but I can't find anything about it on the net. * Consolidated use of asterisk style in exec.cpp.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2011 Haiku, Inc. All Rights Reserved.
|
* Copyright 2004-2015 Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _UNISTD_H_
|
#ifndef _UNISTD_H_
|
||||||
@@ -207,13 +207,15 @@ extern int lockf(int fd, int function, off_t size);
|
|||||||
/* process functions */
|
/* process functions */
|
||||||
extern pid_t fork(void);
|
extern pid_t fork(void);
|
||||||
extern pid_t vfork(void);
|
extern pid_t vfork(void);
|
||||||
extern int execve(const char *path, char * const argv[], char * const envp[]);
|
extern int execve(const char *path, char * const argv[],
|
||||||
|
char *const environment[]);
|
||||||
extern int execl(const char *path, const char *arg, ...);
|
extern int execl(const char *path, const char *arg, ...);
|
||||||
extern int execv(const char *path, char *const *argv);
|
extern int execv(const char *path, char *const argv[]);
|
||||||
extern int execlp(const char *file, const char *arg, ...);
|
extern int execlp(const char *file, const char *arg, ...);
|
||||||
extern int execle(const char *path, const char *arg , ... /*, char **envp */);
|
extern int execle(const char *path, const char *arg , ... /*, char **envp */);
|
||||||
extern int exect(const char *path, char *const *argv);
|
extern int execvp(const char *file, char *const argv[]);
|
||||||
extern int execvp(const char *file, char *const *argv);
|
extern int execvpe(const char *file, char *const argv[],
|
||||||
|
char *const environment[]);
|
||||||
|
|
||||||
extern void _exit(int status) __attribute__ ((noreturn));
|
extern void _exit(int status) __attribute__ ((noreturn));
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008, Ingo Weinhold, [email protected].
|
* Copyright 2008, Ingo Weinhold, [email protected].
|
||||||
* Copyright 2004-2005, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2004-2015, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -135,18 +135,25 @@ execve(const char *path, char* const args[], char* const environment[])
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
execv(const char *path, char * const *argv)
|
execv(const char* path, char* const argv[])
|
||||||
{
|
{
|
||||||
return do_exec(path, argv, environ, false);
|
return do_exec(path, argv, environ, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
execvp(const char *file, char* const* argv)
|
execvp(const char* file, char* const argv[])
|
||||||
|
{
|
||||||
|
return execvpe(file, argv, environ);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
execvpe(const char* file, char* const argv[], char* const environment[])
|
||||||
{
|
{
|
||||||
// let do_exec() handle cases where file is a path (or invalid)
|
// let do_exec() handle cases where file is a path (or invalid)
|
||||||
if (file == NULL || strchr(file, '/') != NULL)
|
if (file == NULL || strchr(file, '/') != NULL)
|
||||||
return do_exec(file, argv, environ, true);
|
return do_exec(file, argv, environment, true);
|
||||||
|
|
||||||
// file is just a leaf name, so we have to look it up in the path
|
// file is just a leaf name, so we have to look it up in the path
|
||||||
|
|
||||||
@@ -189,7 +196,7 @@ execvp(const char *file, char* const* argv)
|
|||||||
|
|
||||||
// if executable, execute it
|
// if executable, execute it
|
||||||
if (access(path, X_OK) == 0)
|
if (access(path, X_OK) == 0)
|
||||||
return do_exec(path, argv, environ, true);
|
return do_exec(path, argv, environment, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
__set_errno(B_ENTRY_NOT_FOUND);
|
__set_errno(B_ENTRY_NOT_FOUND);
|
||||||
@@ -269,11 +276,11 @@ execle(const char *path, const char *arg, ... /*, char **env */)
|
|||||||
return do_exec(path, (char* const*)args, env, false);
|
return do_exec(path, (char* const*)args, env, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove this again if possible
|
||||||
|
extern int exect(const char *path, char *const *argv);
|
||||||
|
|
||||||
int
|
int
|
||||||
exect(const char* path, char* const* argv)
|
exect(const char* path, char* const* argv)
|
||||||
{
|
{
|
||||||
// ToDo: is this any different?
|
|
||||||
return execv(path, argv);
|
return execv(path, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user