[Haskell-cafe] createProcess running non-existent programs

Niklas Hambüchen mail at nh2.me
Fri Aug 31 03:19:30 CEST 2012


Well, overhead or not, it would be nice to at least have *some* solution.

Currently, it just doesn't work.

I am sure that as soon the functionality is there, somebody will step in
to fake it fast.

On 15/08/12 06:25, Donn Cave wrote:
> Quoth Alexander Kjeldaas <alexander.kjeldaas at gmail.com>,
> 
>> See access(2)
> 
> ... a classic "code smell" in UNIX programming, for the same reasons.
> 
> We can solve this problem in an efficient way that works well, and equally
> well, on any POSIX platform that supports F_CLOEXEC on pipes, and I can't
> think of anything that doesn't.  The appended code is the basic gist of it.
> This was not invented by the Python world, but as suggested it's one of
> the things that we'd get from a review of their subprocess module.
> 
> 	Donn
> 
> spawn file cmd env = do
>   (e0, e1) <- pipe
>   fcntlSetFlag e1 F_CLOEXEC
>   t <- fork (fex e0 e1)
>   close e1
>   rx <- readFd e0 256
>   if null rx
>      then return t
>      else ioerr (chrToErrType rx) file
>   where
>      fex e0 e1 = do
>        close e0
>        catch  (execve file cmd env)
>               (\ e -> writeFd e1 (errToChr e : ioeGetErrorString e))
>      ioerr (e, s) file = ioError (mkIOError e s Nothing (Just file))
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 



More information about the Haskell-Cafe mailing list