haskell / process

Library for dealing with system processes
http://hackage.haskell.org/package/process
Other
87 stars 82 forks source link

Problems with pcWorkingDir on macOS #171

Open k-bx opened 4 years ago

k-bx commented 4 years ago

Migrating from https://github.com/fpco/typed-process/issues/31

Here's a script that works differently on macOS and Linux.

#!/usr/bin/env stack
{- stack script
     --resolver=lts-15.0
     --package process
-}
{-# LANGUAGE OverloadedStrings #-}

import Control.Concurrent
import System.Exit (ExitCode(..))
import qualified System.Process as P

main :: IO ()
main = do
  let cp0 = P.proc "./webapp" []
      pcWorkingDir = Just "./inner"
      cp = cp0 {P.cwd = pcWorkingDir}
  (minH, moutH, merrH, pHandle) <- P.createProcess_ "startProcess" cp
  putStrLn "> started"
  threadDelay (2 * 1000000)
  putStrLn "> exiting"

The problem is that it succeeds in running a program ./webapp located in ./inner dir on Linux, but fails on macOS. If you put "./inner/webapp" as a path on macOS, it launches it fine.

Dir where you can reproduce this in full: https://github.com/k-bx/playground/tree/master/typed-process-issue-31

snoyberg commented 4 years ago

As I mentioned in that previous issue, I think this is an inherent difference in Mac vs Linux, though I could be mistaken. I'm worried about trying to fix this one, as it will silently change the behavior of programs on one of these two OSes. If we can do it with a flag, that would be better.