diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-10-11 01:13:48 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-10-11 01:13:48 +0200 |
commit | 5224a569fa9c262d364e640d31871f50f047ac9e (patch) | |
tree | 8650fa3b6b25f57268bd44a7eb314585c1e3ff08 /include | |
parent | string.h may include strings.h (diff) | |
download | slibc-5224a569fa9c262d364e640d31871f50f047ac9e.tar.gz slibc-5224a569fa9c262d364e640d31871f50f047ac9e.tar.bz2 slibc-5224a569fa9c262d364e640d31871f50f047ac9e.tar.xz |
add exec functions
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/unistd.h | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/include/unistd.h b/include/unistd.h index 6fa36bb..f85c1ae 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -143,5 +143,191 @@ int isatty(int); +/** + * Replace the current process image with a new process image. + * + * @param path The pathname of the file to execute. + * @param ... The arguments with which to execute the file. + * The arguments should have the type `const char*`. + * As a slibc extension, it can be empty. + * This list shall be terminated by a `NULL` sentinel. + * @return This function does not return on success, + * on error, -1 is returned and `errno` is + * set to describe the error. + * + * @throws Any error specified for execve(2). + */ +int execl(const char*, ... /*, NULL */) + __GCC_ONLY(__attribute__((sentinel(0), nonnull(1)))); + +/** + * Replace the current process image with a new process image. + * + * @param file The pathname of the file to execute, + * or the filename of a file in $PATH, + * to execute. + * @param ... The arguments with which to execute the file. + * The arguments should have the type `const char*`. + * As a slibc extension, it can be empty. + * This list shall be terminated by a `NULL` sentinel. + * @return This function does not return on success, + * on error, -1 is returned and `errno` is + * set to describe the error. + * + * @throws Any error specified for execve(2). + */ +int execlp(const char*, ... /*, NULL */) + __GCC_ONLY(__attribute__((sentinel(0), nonnull(1)))); + +/** + * Replace the current process image with a new process image. + * + * @param path The pathname of the file to execute. + * @param ... The arguments with which to execute the file. + * The arguments should have the type `const char*`. + * As a slibc extension, it can be empty. + * This list shall be terminated by a `NULL` sentinel. + * @param envp The list of environment variables the new program shall + * have set. Each element shall be foramtted $name=$value. + * This list shall be `NULL`-terminated. The behaviour + * is system-dependant if this argument is `NULL`. + * @return This function does not return on success, + * on error, -1 is returned and `errno` is + * set to describe the error. + * + * @throws Any error specified for execve(2). + */ +int execle(const char*, ... /*, NULL, char* const[] */) + __GCC_ONLY(__attribute__((sentinel(1), nonnull(1)))); + +#if (defined(_SLIBC_SOURCE) && !defined(__PORTABLE)) +/** + * Replace the current process image with a new process image. + * + * This is a slibc extension, added for completeness. + * + * @param file The pathname of the file to execute, + * or the filename of a file in $PATH, + * to execute. + * @param ... The arguments with which to execute the file. + * The arguments should have the type `const char*`. + * As a slibc extension, it can be empty. + * This list shall be terminated by a `NULL` sentinel. + * @param envp The list of environment variables the new program shall + * have set. Each element shall be foramtted $name=$value. + * This list shall be `NULL`-terminated. The behaviour + * is system-dependant if this argument is `NULL`. + * @return This function does not return on success, + * on error, -1 is returned and `errno` is + * set to describe the error. + * + * @throws Any error specified for execve(2). + */ +int execlpe(const char*, ... /*, NULL, char* const[] */) + __GCC_ONLY(__attribute__((sentinel(1), nonnull(1)))); +#endif + +/** + * Replace the current process image with a new process image. + * + * @param path The pathname of the file to execute. + * @param argv The arguments with which to execute the file. + * This parameter should really have the type + * `const char* const[]`, but that probably not + * so because compiles take issue with casts + * adding const to any pointer in the type + * except the outmost pointer. This list shall + * be `NULL`-terminated. The behaviour is + * system-dependant if this argument is `NULL`. + * @return This function does not return on success, + * on error, -1 is returned and `errno` is + * set to describe the error. + * + * @throws Any error specified for execve(2). + */ +int execv(const char*, char* const[]) + __GCC_ONLY(__attribute__((nonnull(1)))); + +/** + * Replace the current process image with a new process image. + * + * @param file The pathname of the file to execute, + * or the filename of a file in $PATH, + * to execute. + * @param argv The arguments with which to execute the file. + * This parameter should really have the type + * `const char* const[]`, but that probably not + * so because compiles take issue with casts + * adding const to any pointer in the type + * except the outmost pointer. This list shall + * be `NULL`-terminated. The behaviour is + * system-dependant if this argument is `NULL`. + * @return This function does not return on success, + * on error, -1 is returned and `errno` is + * set to describe the error. + * + * @throws Any error specified for execve(2). + */ +int execvp(const char*, char* const[]) + __GCC_ONLY(__attribute__((nonnull(1)))); + +/** + * Replace the current process image with a new process image. + * + * @param path The pathname of the file to execute. + * @param argv The arguments with which to execute the file. + * This parameter should really have the type + * `const char* const[]`, but that probably not + * so because compiles take issue with casts + * adding const to any pointer in the type + * except the outmost pointer. This list shall + * be `NULL`-terminated. The behaviour is + * system-dependant if this argument is `NULL`. + * @param envp The list of environment variables the new program shall + * have set. Each element shall be foramtted $name=$value. + * This list shall be `NULL`-terminated. The behaviour + * is system-dependant if this argument is `NULL`. + * @return This function does not return on success, + * on error, -1 is returned and `errno` is + * set to describe the error. + * + * @throws Any error specified for execve(2). + */ +int execve(const char*, char* const[], char* const[]) + __GCC_ONLY(__attribute__((nonnull(1)))); + +#if (defined(_GNU_SOURCE) || defined(_SLIBC_SOURCE)) && !defined(__PORTABLE) +/** + * Replace the current process image with a new process image. + * + * This is a GNU-compliant slibc extension. + * + * @param file The pathname of the file to execute, + * or the filename of a file in $PATH, + * to execute. + * @param argv The arguments with which to execute the file. + * This parameter should really have the type + * `const char* const[]`, but that probably not + * so because compiles take issue with casts + * adding const to any pointer in the type + * except the outmost pointer. This list shall + * be `NULL`-terminated. The behaviour is + * system-dependant if this argument is `NULL`. + * @param envp The list of environment variables the new program shall + * have set. Each element shall be foramtted $name=$value. + * This list shall be `NULL`-terminated. The behaviour + * is system-dependant if this argument is `NULL`. + * @return This function does not return on success, + * on error, -1 is returned and `errno` is + * set to describe the error. + * + * @throws Any error specified for execve(2). + */ +int execvpe(const char*, char* const[], char* const[]) + __GCC_ONLY(__attribute__((nonnull(1)))); +#endif + + + #endif |