aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/posix
diff options
context:
space:
mode:
authorRoland McGrath <mcgrathr@chromium.org>2011-09-19 12:50:25 -0700
committerRoland McGrath <mcgrathr@chromium.org>2011-09-19 12:50:25 -0700
commitecb1482ffd85fd3279642b1dc045aa867ad4d415 (patch)
treec8276d86e38abbf88c191dc3623cac89b6425c7c /sysdeps/posix
parentbc7e1c3667b577ad418f7520df2a7dbccea04ee9 (diff)
downloadglibc-ecb1482ffd85fd3279642b1dc045aa867ad4d415.tar
glibc-ecb1482ffd85fd3279642b1dc045aa867ad4d415.tar.gz
glibc-ecb1482ffd85fd3279642b1dc045aa867ad4d415.tar.bz2
glibc-ecb1482ffd85fd3279642b1dc045aa867ad4d415.zip
Clean up disabling of script_execute
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/spawni.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c
index 129edcd6d4..f849437a48 100644
--- a/sysdeps/posix/spawni.c
+++ b/sysdeps/posix/spawni.c
@@ -39,7 +39,6 @@
#define SPAWN_ERROR 127
-#if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_15)
/* The file is accessible but it is not an executable file. Invoke
the shell to interpret it as a script. */
static void
@@ -66,11 +65,16 @@ script_execute (const char *file, char *const argv[], char *const envp[])
__execve (new_argv[0], new_argv, envp);
}
}
-# define tryshell (xflags & SPAWN_XFLAGS_TRY_SHELL)
-#else
-# define tryshell 0
-#endif
+static inline void
+maybe_script_execute (const char *file, char *const argv[], char *const envp[],
+ int xflags)
+{
+ if (SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_15)
+ && (xflags & SPAWN_XFLAGS_TRY_SHELL)
+ && errno == ENOEXEC)
+ script_execute (file, argv, envp);
+}
/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
Before running the process perform the actions described in FILE-ACTIONS. */
@@ -237,8 +241,7 @@ __spawni (pid_t *pid, const char *file,
/* The FILE parameter is actually a path. */
__execve (file, argv, envp);
- if (tryshell && errno == ENOEXEC)
- script_execute (file, argv, envp);
+ maybe_script_execute (file, argv, envp, xflags);
/* Oh, oh. `execve' returns. This is bad. */
_exit (SPAWN_ERROR);
@@ -283,8 +286,7 @@ __spawni (pid_t *pid, const char *file,
/* Try to execute this name. If it works, execv will not return. */
__execve (startp, argv, envp);
- if (tryshell && errno == ENOEXEC)
- script_execute (startp, argv, envp);
+ maybe_script_execute (startp, argv, envp, xflags);
switch (errno)
{