diff options
author | davidxu <davidxu@FreeBSD.org> | 2008-06-19 02:42:50 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2008-06-19 02:42:50 +0000 |
commit | 6acc22fcf7b38044376e58f542a2872e27c7b18d (patch) | |
tree | d4608acd2cb0a5b70c0abe6ebe3ee89cd49586c5 /lib/libc/gen | |
parent | 3807b1c27a2e93b9327c523426ce9e58c5d7a479 (diff) | |
download | FreeBSD-src-6acc22fcf7b38044376e58f542a2872e27c7b18d.zip FreeBSD-src-6acc22fcf7b38044376e58f542a2872e27c7b18d.tar.gz |
Process spawn attributes in POSIX document order.
Diffstat (limited to 'lib/libc/gen')
-rw-r--r-- | lib/libc/gen/posix_spawn.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c index 6f44d44..a587d9e 100644 --- a/lib/libc/gen/posix_spawn.c +++ b/lib/libc/gen/posix_spawn.c @@ -92,27 +92,6 @@ process_spawnattr(const posix_spawnattr_t sa) * are mentioned. */ - /* Set signal masks/defaults */ - if (sa->sa_flags & POSIX_SPAWN_SETSIGMASK) { - _sigprocmask(SIG_SETMASK, &sa->sa_sigmask, NULL); - } - - if (sa->sa_flags & POSIX_SPAWN_SETSIGDEF) { - for (i = 1; i <= _SIG_MAXSIG; i++) { - if (sigismember(&sa->sa_sigdefault, i)) - if (_sigaction(i, &sigact, NULL) != 0) - return (errno); - } - } - - /* Reset user ID's */ - if (sa->sa_flags & POSIX_SPAWN_RESETIDS) { - if (setegid(getgid()) != 0) - return (errno); - if (seteuid(getuid()) != 0) - return (errno); - } - /* Set process group */ if (sa->sa_flags & POSIX_SPAWN_SETPGROUP) { if (setpgid(0, sa->sa_pgroup) != 0) @@ -128,6 +107,28 @@ process_spawnattr(const posix_spawnattr_t sa) if (sched_setparam(0, &sa->sa_schedparam) != 0) return (errno); } + + /* Reset user ID's */ + if (sa->sa_flags & POSIX_SPAWN_RESETIDS) { + if (setegid(getgid()) != 0) + return (errno); + if (seteuid(getuid()) != 0) + return (errno); + } + + /* Set signal masks/defaults */ + if (sa->sa_flags & POSIX_SPAWN_SETSIGMASK) { + _sigprocmask(SIG_SETMASK, &sa->sa_sigmask, NULL); + } + + if (sa->sa_flags & POSIX_SPAWN_SETSIGDEF) { + for (i = 1; i <= _SIG_MAXSIG; i++) { + if (sigismember(&sa->sa_sigdefault, i)) + if (_sigaction(i, &sigact, NULL) != 0) + return (errno); + } + } + return (0); } |