You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/04/22 07:40:38 UTC

[incubator-nuttx] 02/02: libc: Implement execvp, execlp and execvpe as macro

This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 49eb2bd41594e17cb0e2fa55f290f789b31c3aaa
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Wed Apr 20 21:21:21 2022 +0800

    libc: Implement execvp, execlp and execvpe as macro
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 include/spawn.h  |  9 +++++++--
 include/unistd.h | 11 +++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/include/spawn.h b/include/spawn.h
index 83e32202a2..dbecd88f12 100644
--- a/include/spawn.h
+++ b/include/spawn.h
@@ -54,6 +54,13 @@
 #define POSIX_SPAWN_SETSIGMASK    (1 << 5)  /* 1: Set sigmask */
 #define POSIX_SPAWN_SETSID        (1 << 7)  /* 1: Create the new session(glibc specific) */
 
+/* NOTE: NuttX provides only one implementation:  If
+ * CONFIG_LIBC_ENVPATH is defined, then only posix_spawnp() behavior
+ * is supported; otherwise, only posix_spawn behavior is supported.
+ */
+
+#define posix_spawnp              posix_spawn
+
 /****************************************************************************
  * Type Definitions
  ****************************************************************************/
@@ -129,8 +136,6 @@ int posix_spawn(FAR pid_t *pid, FAR const char *path,
       FAR const posix_spawn_file_actions_t *file_actions,
       FAR const posix_spawnattr_t *attr,
       FAR char * const argv[], FAR char * const envp[]);
-#define posix_spawnp(pid,path,file_actions,attr,argv,envp) \
-      posix_spawn(pid,path,file_actions,attr,argv,envp)
 
 #ifndef CONFIG_BUILD_KERNEL
 /* Non-standard task_spawn interface.  This function uses the same
diff --git a/include/unistd.h b/include/unistd.h
index de35eb42dd..e754e0a804 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -280,6 +280,17 @@
 #  define lockf64                        lockf
 #endif
 
+/* NOTE: NuttX provides only one implementation:  If
+ * CONFIG_LIBC_ENVPATH is defined, then only execvp/execlp/execvpe behavior
+ * is supported; otherwise, only execv/execl/execve behavior is supported.
+ */
+
+#ifdef CONFIG_LIBC_EXECFUNCS
+#  define execvp                         execv
+#  define execlp                         execl
+#  define execvpe                        execve
+#endif
+
 /****************************************************************************
  * Public Data
  ****************************************************************************/