process 1.6.13.0 → 1.6.13.1
raw patch · 8 files changed
+113/−13 lines, 8 files
Files
- cbits/posix/common.h +52/−0
- cbits/posix/find_executable.c +10/−1
- cbits/posix/fork_exec.c +7/−3
- cbits/posix/posix_spawn.c +11/−2
- changelog.md +4/−0
- configure +15/−3
- configure.ac +12/−3
- process.cabal +2/−1
+ cbits/posix/common.h view
@@ -0,0 +1,52 @@+#pragma once++#include "runProcess.h"++enum std_handle_behavior {+ // Close the handle+ STD_HANDLE_CLOSE,+ // dup2 the specified fd to standard handle+ STD_HANDLE_USE_FD,+ // dup2 the appropriate end of the given pipe to the standard handle and+ // close the other end.+ STD_HANDLE_USE_PIPE+};++struct std_handle {+ enum std_handle_behavior behavior;+ union {+ int use_fd;+ struct {+ int parent_end, child_end;+ } use_pipe;+ };+};++int get_max_fd(void);++// defined in find_executable.c+#if !defined(HAVE_execvpe)+char *find_executable(char *filename);+#endif++// defined in fork_exec.c+ProcHandle+do_spawn_fork (char *const args[],+ char *workingDirectory, char **environment,+ struct std_handle *stdInHdl,+ struct std_handle *stdOutHdl,+ struct std_handle *stdErrHdl,+ gid_t *childGroup, uid_t *childUser,+ int flags,+ char **failed_doing);++// defined in posix_spawn.c+ProcHandle+do_spawn_posix (char *const args[],+ char *workingDirectory, char **environment,+ struct std_handle *stdInHdl,+ struct std_handle *stdOutHdl,+ struct std_handle *stdErrHdl,+ gid_t *childGroup, uid_t *childUser,+ int flags,+ char **failed_doing);
cbits/posix/find_executable.c view
@@ -11,7 +11,7 @@ #include "common.h" -// the below is only necessary when we don't have execvpe.+// the below is only necessary when we need to emulate execvpe. #if !defined(HAVE_execvpe) /* Return true if the given file exists and is an executable. */@@ -28,7 +28,16 @@ char *tokbuf; char *path = strtok_r(search_path, ":", &tokbuf); while (path != NULL) {+ // N.B. gcc 6.3.0, used by Debian 9, inexplicably warns that `path`+ // may not be initialised with -Wall. Silence this warning. See #210.+#if defined(__GNUC__) && __GNUC__ == 6 && __GNUC_MINOR__ == 3+#pragma GCC diagnostic push+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"+#endif const int tmp_len = filename_len + 1 + strlen(path) + 1;+#if defined(__GNUC__) && __GNUC__ == 6 && __GNUC_MINOR__ == 3+#pragma GCC diagnostic pop+#endif char *tmp = malloc(tmp_len); snprintf(tmp, tmp_len, "%s/%s", path, filename); if (is_executable(tmp)) {
cbits/posix/fork_exec.c view
@@ -62,7 +62,6 @@ case STD_HANDLE_CLOSE: if (close(fd) == -1) { child_failed(pipe, "close");- return -1; } return 0; @@ -84,7 +83,12 @@ if (close(b->use_pipe.parent_end) == -1) { child_failed(pipe, "close(parent_end)"); }- break;+ return 0;++ default:+ // N.B. this should be unreachable but some compilers apparently can't+ // see this.+ child_failed(pipe, "setup_std_handle_fork(invalid behavior)"); } } @@ -219,7 +223,7 @@ /* Reset the SIGINT/SIGQUIT signal handlers in the child, if requested */- if (flags & RESET_INT_QUIT_HANDLERS != 0) {+ if ((flags & RESET_INT_QUIT_HANDLERS) != 0) { struct sigaction dfl; (void)sigemptyset(&dfl.sa_mask); dfl.sa_flags = 0;
cbits/posix/posix_spawn.c view
@@ -64,6 +64,13 @@ return -1; } return 0;++ default:+ // N.B. this should be unreachable+ // but some compilers apparently can't+ // see this.+ *failed_doing = "posix_spawn_file_actions_addclose(invalid behavior)";+ return -1; } } @@ -143,11 +150,13 @@ #endif } -#if defined(HAVE_POSIX_SPAWN_SETPGROUP) if ((flags & RUN_PROCESS_IN_NEW_GROUP) != 0) {+#if defined(HAVE_POSIX_SPAWN_SETPGROUP) spawn_flags |= POSIX_SPAWN_SETPGROUP;- }+#else+ goto not_supported; #endif+ } if (setup_std_handle_spawn(STDIN_FILENO, stdInHdl, &fa, failed_doing) != 0) { goto fail;
changelog.md view
@@ -1,5 +1,9 @@ # Changelog for [`process` package](http://hackage.haskell.org/package/process) +## 1.6.13.1 *July 2021*++* Patches for the previous release+ ## 1.6.13.0 *July 2021* * Refactoring of POSIX process logic [#208](https://github.com/haskell/process/pull/208)
configure view
@@ -3862,7 +3862,11 @@ fi done -ac_fn_c_check_decl "$LINENO" "POSIX_SPAWN_SETSID" "ac_cv_have_decl_POSIX_SPAWN_SETSID" "$ac_includes_default"+ac_fn_c_check_decl "$LINENO" "POSIX_SPAWN_SETSID" "ac_cv_have_decl_POSIX_SPAWN_SETSID" "+ #define _GNU_SOURCE+ #include <spawn.h>++" if test "x$ac_cv_have_decl_POSIX_SPAWN_SETSID" = xyes; then : ac_have_decl=1 else@@ -3872,7 +3876,11 @@ cat >>confdefs.h <<_ACEOF #define HAVE_DECL_POSIX_SPAWN_SETSID $ac_have_decl _ACEOF-ac_fn_c_check_decl "$LINENO" "POSIX_SPAWN_SETSID_NP" "ac_cv_have_decl_POSIX_SPAWN_SETSID_NP" "$ac_includes_default"+ac_fn_c_check_decl "$LINENO" "POSIX_SPAWN_SETSID_NP" "ac_cv_have_decl_POSIX_SPAWN_SETSID_NP" "+ #define _GNU_SOURCE+ #include <spawn.h>++" if test "x$ac_cv_have_decl_POSIX_SPAWN_SETSID_NP" = xyes; then : ac_have_decl=1 else@@ -3883,7 +3891,11 @@ #define HAVE_DECL_POSIX_SPAWN_SETSID_NP $ac_have_decl _ACEOF -ac_fn_c_check_decl "$LINENO" "POSIX_SPAWN_SETPGROUP" "ac_cv_have_decl_POSIX_SPAWN_SETPGROUP" "$ac_includes_default"+ac_fn_c_check_decl "$LINENO" "POSIX_SPAWN_SETPGROUP" "ac_cv_have_decl_POSIX_SPAWN_SETPGROUP" "+ #define _GNU_SOURCE+ #include <spawn.h>++" if test "x$ac_cv_have_decl_POSIX_SPAWN_SETPGROUP" = xyes; then : ac_have_decl=1 else
configure.ac view
@@ -18,9 +18,18 @@ # posix_spawn checks AC_CHECK_HEADERS([spawn.h])-AC_CHECK_FUNCS([posix_spawnp posix_spawn_file_actions_addchdir])-AC_CHECK_DECLS([POSIX_SPAWN_SETSID, POSIX_SPAWN_SETSID_NP])-AC_CHECK_DECLS([POSIX_SPAWN_SETPGROUP])+AC_CHECK_FUNCS([posix_spawnp posix_spawn_file_actions_addchdir],[],[],[+ #define _GNU_SOURCE+ #include <spawn.h>+])+AC_CHECK_DECLS([POSIX_SPAWN_SETSID, POSIX_SPAWN_SETSID_NP],[],[],[+ #define _GNU_SOURCE+ #include <spawn.h>+])+AC_CHECK_DECLS([POSIX_SPAWN_SETPGROUP],[],[],[+ #define _GNU_SOURCE+ #include <spawn.h>+]) FP_CHECK_CONSTS([SIG_DFL SIG_IGN])
process.cabal view
@@ -1,5 +1,5 @@ name: process-version: 1.6.13.0+version: 1.6.13.1 -- NOTE: Don't forget to update ./changelog.md license: BSD3 license-file: LICENSE@@ -27,6 +27,7 @@ process.buildinfo exes/echo.bat exes/subdir/echo.bat+ cbits/posix/common.h extra-tmp-files: autom4te.cache