Skip to content

Commit

Permalink
Clean up disabling of script_execute
Browse files Browse the repository at this point in the history
  • Loading branch information
Roland McGrath committed Sep 19, 2011
1 parent bc7e1c3 commit ecb1482
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
2011-09-19 Roland McGrath <roland@hack.frob.com>

* sysdeps/posix/spawni.c (script_execute): Always define it.
It will be optimized away if unused.
(maybe_script_execute): New function.
(__spawni): Call it.

* Makerules: Don't include tls.make.
(config-tls): Always set to thread.
* tls.make.c: File removed.
Expand Down
20 changes: 11 additions & 9 deletions sysdeps/posix/spawni.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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. */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit ecb1482

Please sign in to comment.