diff options
-rw-r--r-- | INSTALL | 1 | ||||
-rw-r--r-- | doc/index.html | 2 | ||||
-rw-r--r-- | doc/upgrade.html | 9 | ||||
-rw-r--r-- | package/info | 2 | ||||
-rw-r--r-- | src/libstddjb/child_spawn.c | 5 | ||||
-rw-r--r-- | src/libstddjb/child_spawn0.c | 29 | ||||
-rw-r--r-- | src/libstddjb/child_spawn1_internal.c | 5 |
7 files changed, 44 insertions, 9 deletions
@@ -34,7 +34,6 @@ before the "make install" phase. It will shave a few bytes off them. See ./configure --help for a list of all available configure options. - * Environment variables --------------------- diff --git a/doc/index.html b/doc/index.html index f4f9062..e0f8432 100644 --- a/doc/index.html +++ b/doc/index.html @@ -59,7 +59,7 @@ with a standard C development environment </li> <h3> Download </h3> <ul> - <li> The current released version of skalibs is <a href="skalibs-2.3.1.1.tar.gz">2.3.1.1</a>. </li> + <li> The current released version of skalibs is <a href="skalibs-2.3.1.2.tar.gz">2.3.1.2</a>. </li> <li> Alternatively, you can checkout a copy of the skalibs git repository: <pre> git clone git://git.skarnet.org/skalibs </pre> </li> </ul> diff --git a/doc/upgrade.html b/doc/upgrade.html index fbe1cdd..16a0be2 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -17,6 +17,15 @@ <h1> What has changed in skalibs </h1> +<h2> in 2.3.1.2 </h2> + +<ul> + <li> The child_spawn* family of functions now resets all signals +to their default values when spawning a program on systems with +<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html">posix_spawn()</a>. +This should not change anything - it's just paranoia. </li> +</ul> + <h2> in 2.3.1.1 </h2> <ul> diff --git a/package/info b/package/info index 94f7245..4b16262 100644 --- a/package/info +++ b/package/info @@ -1,4 +1,4 @@ package=skalibs -version=2.3.1.1 +version=2.3.1.2 category=prog package_macro_name=SKALIBS diff --git a/src/libstddjb/child_spawn.c b/src/libstddjb/child_spawn.c index a9003e5..a9938c7 100644 --- a/src/libstddjb/child_spawn.c +++ b/src/libstddjb/child_spawn.c @@ -74,8 +74,11 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const sigset_t set ; sigemptyset(&set) ; e = posix_spawnattr_setsigmask(&attr, &set) ; + if (e) goto errattr ; + sigfillset(&set) ; + e = posix_spawnattr_setsigdefault(&attr, &set) ; + if (e) goto errattr ; } - if (e) goto errattr ; e = posix_spawn_file_actions_init(&actions) ; if (e) goto errattr ; if (n >= 2) diff --git a/src/libstddjb/child_spawn0.c b/src/libstddjb/child_spawn0.c index b96b2ef..7129515 100644 --- a/src/libstddjb/child_spawn0.c +++ b/src/libstddjb/child_spawn0.c @@ -6,6 +6,7 @@ #ifdef SKALIBS_HASPOSIXSPAWN +#include <signal.h> #include <spawn.h> #include <stdlib.h> #include <skalibs/config.h> @@ -13,13 +14,33 @@ pid_t child_spawn0 (char const *prog, char const *const *argv, char const *const *envp) { - pid_t pid ; + posix_spawnattr_t attr ; int e ; + pid_t pid ; int haspath = !!env_get("PATH") ; - if (!haspath && (setenv("PATH", SKALIBS_DEFAULTPATH, 0) < 0)) return 0 ; - e = posix_spawnp(&pid, prog, 0, 0, (char *const *)argv, (char *const *)envp) ; + e = posix_spawnattr_init(&attr) ; + if (e) goto err ; + { + sigset_t set ; + sigemptyset(&set) ; + e = posix_spawnattr_setsigmask(&attr, &set) ; + if (e) goto errattr ; + sigfillset(&set) ; + e = posix_spawnattr_setsigdefault(&attr, &set) ; + if (e) goto errattr ; + } + if (!haspath && (setenv("PATH", SKALIBS_DEFAULTPATH, 0) < 0)) { e = errno ; goto errattr ; } + e = posix_spawnp(&pid, prog, 0, &attr, (char *const *)argv, (char *const *)envp) ; if (!haspath) unsetenv("PATH") ; - return e ? (errno = e, 0) : pid ; + posix_spawnattr_destroy(&attr) ; + if (e) goto err ; + return pid ; + + errattr: + posix_spawnattr_destroy(&attr) ; + err: + errno = e ; + return 0 ; } #else diff --git a/src/libstddjb/child_spawn1_internal.c b/src/libstddjb/child_spawn1_internal.c index 2ce2ac3..8347f69 100644 --- a/src/libstddjb/child_spawn1_internal.c +++ b/src/libstddjb/child_spawn1_internal.c @@ -28,8 +28,11 @@ pid_t child_spawn1_internal (char const *prog, char const *const *argv, char con sigset_t set ; sigemptyset(&set) ; e = posix_spawnattr_setsigmask(&attr, &set) ; + if (e) goto errattr ; + sigfillset(&set) ; + e = posix_spawnattr_setsigdefault(&attr, &set) ; + if (e) goto errattr ; } - if (e) goto errattr ; e = posix_spawn_file_actions_init(&actions) ; if (e) goto errattr ; e = posix_spawn_file_actions_adddup2(&actions, p[to & 1], to & 1) ; |