Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export runInteractiveProcess_lock on Posix systems #154

Merged
merged 3 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions System/Process/Internals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module System.Process.Internals (
#else
pPrPr_disableITimers, c_execvpe,
ignoreSignal, defaultSignal,
runInteractiveProcess_lock,
#endif
withFilePathException, withCEnvironment,
translate,
Expand Down
15 changes: 11 additions & 4 deletions System/Process/Posix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module System.Process.Posix
, createPipeInternal
, createPipeInternalFd
, interruptProcessGroupOfInternal
, runInteractiveProcess_lock
) where

import Control.Concurrent
Expand Down Expand Up @@ -138,10 +139,7 @@ createProcess_Internal fun
when mb_delegate_ctlc
startDelegateControlC

-- runInteractiveProcess() blocks signals around the fork().
-- Since blocking/unblocking of signals is a global state
-- operation, we better ensure mutual exclusion of calls to
-- runInteractiveProcess().
-- See the comment on runInteractiveProcess_lock
proc_handle <- withMVar runInteractiveProcess_lock $ \_ ->
c_runInteractiveProcess pargs pWorkDir pEnv
fdin fdout fderr
Expand Down Expand Up @@ -174,6 +172,15 @@ createProcess_Internal fun
}

{-# NOINLINE runInteractiveProcess_lock #-}
-- | 'runInteractiveProcess' blocks signals around the fork().
-- Since blocking/unblocking of signals is a global state operation, we need to
-- ensure mutual exclusion of calls to 'runInteractiveProcess'.
-- This lock is exported so that other libraries which also need to fork()
-- (and also need to make the same global state changes) can protect their changes
-- with the same lock.
-- See https://github.com/haskell/process/pull/154.
--
-- @since 1.6.6.0
runInteractiveProcess_lock :: MVar ()
runInteractiveProcess_lock = unsafePerformIO $ newMVar ()

Expand Down
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog for [`process` package](http://hackage.haskell.org/package/process)

## Unreleased changes
## 1.6.6.0 *September 2019*

* Fix a potential privilege escalation issue (or, more precisely, privileges
not being dropped when this was the user's intent) where the groups of the
Expand All @@ -9,6 +9,8 @@
* Bug fix: Prevent stripping undecodable bytes from environment variables
when in a non-unicode locale.
[#152](https://github.com/haskell/process/issues/152)
* Expose `runInteractiveProcess_lock` in `System.Process.Internals`
[#154](https://github.com/haskell/process/pull/154)

## 1.6.5.1 *June 2019*

Expand Down