From 6fe752f94f16b278f3415d82b202d32aab7ad84d Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 26 Nov 2013 13:48:00 +0000 Subject: [PATCH] * libc/posix/posix_spawn.c: Eliminate OS function calls not present in newlib or Cygwin. (process_spawnattr): Use sigprocmask rather than _sigprocmask. Use sigaction rather than _sigaction. (process_file_actions_entry): Use dup2 rather than _dup2. (do_posix_spawn): Use execvpe rather than _execvpe. Use waitpid rather than _waitpid. --- newlib/ChangeLog | 10 ++++++++++ newlib/libc/posix/posix_spawn.c | 18 +++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index f483032cf..f2c9dbaa9 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,13 @@ +2013-11-26 Corinna Vinschen + + * libc/posix/posix_spawn.c: Eliminate OS function calls not present + in newlib or Cygwin. + (process_spawnattr): Use sigprocmask rather than _sigprocmask. Use + sigaction rather than _sigaction. + (process_file_actions_entry): Use dup2 rather than _dup2. + (do_posix_spawn): Use execvpe rather than _execvpe. Use waitpid + rather than _waitpid. + 2013-11-25 Joel Sherrill * libc/iconv/lib/iconv.c, libc/time/strftime.c: Change "restrict<" to diff --git a/newlib/libc/posix/posix_spawn.c b/newlib/libc/posix/posix_spawn.c index 2d273708d..d27c08ac0 100644 --- a/newlib/libc/posix/posix_spawn.c +++ b/newlib/libc/posix/posix_spawn.c @@ -80,9 +80,9 @@ argument is unspecified. PORTABILITY POSIX.1-2008 requires <> and <>. -Supporting OS subroutines required: <<_close>>, <<_dup2>>, <<_fcntl>>, -<<_execve>>, <<_execvpe>>, <<_exit>>, <<_open>>, <<_sigaction>>, -<<_sigprocmask>>, <<_waitpid>>, <>, +Supporting OS subroutines required: <<_close>>, <>, <<_fcntl>>, +<<_execve>>, <>, <<_exit>>, <<_open>>, <>, +<>, <>, <>, <>, <>, <>, <>, <>. */ @@ -186,13 +186,13 @@ process_spawnattr(_CONST posix_spawnattr_t sa) /* Set signal masks/defaults */ if (sa->sa_flags & POSIX_SPAWN_SETSIGMASK) { - _sigprocmask(SIG_SETMASK, &sa->sa_sigmask, NULL); + sigprocmask(SIG_SETMASK, &sa->sa_sigmask, NULL); } if (sa->sa_flags & POSIX_SPAWN_SETSIGDEF) { for (i = 1; i < NSIG; i++) { if (sigismember(&sa->sa_sigdefault, i)) - if (_sigaction(i, &sigact, NULL) != 0) + if (sigaction(i, &sigact, NULL) != 0) return (errno); } } @@ -212,7 +212,7 @@ process_file_actions_entry(posix_spawn_file_actions_entry_t *fae) if (fd < 0) return (errno); if (fd != fae->fae_fildes) { - if (_dup2(fd, fae->fae_fildes) == -1) + if (dup2(fd, fae->fae_fildes) == -1) return (errno); if (_close(fd) != 0) { if (errno == EBADF) @@ -226,7 +226,7 @@ process_file_actions_entry(posix_spawn_file_actions_entry_t *fae) break; case FAE_DUP2: /* Perform a dup2() */ - if (_dup2(fae->fae_fildes, fae->fae_newfildes) == -1) + if (dup2(fae->fae_fildes, fae->fae_newfildes) == -1) return (errno); #ifdef HAVE_FCNTL if (_fcntl(fae->fae_newfildes, F_SETFD, 0) == -1) @@ -281,14 +281,14 @@ do_posix_spawn(pid_t *pid, _CONST char *path, _exit(127); } if (use_env_path) - _execvpe(path, argv, envp != NULL ? envp : *p_environ); + execvpe(path, argv, envp != NULL ? envp : *p_environ); else _execve(path, argv, envp != NULL ? envp : *p_environ); error = errno; _exit(127); default: if (error != 0) - _waitpid(p, NULL, WNOHANG); + waitpid(p, NULL, WNOHANG); else if (pid != NULL) *pid = p; return (error);