Re: [Haskell-cafe] executeFile failing on macosx

2010-05-18 Thread Donn Cave
Quoth David Powell da...@drp.id.au,

 Indeed System.Process does work for me.  I had avoided it because it is a
 little more awkward to use it when you want the actual PIDs.  I don't
 understand why System.Process.runProcess works for me, but executeFile does
 not.  I did find this issue (for python)
 http://bugs.python.org/issue6800 which I think is the same thing I'm
 hitting and they also claim it is fixed
 in macosx 10.6.

 Anyway, I'll work with System.Process for now.  Thanks for your help.

It looks to me like the principal difference between System.Process and
executeFile is that the former forks and execs in the same C function,
so the GHC runtime doesn't execute in the child process.  From the OS,
that difference isn't significant, so I wouldn't look for a MacOS bug
here.

On the platform I'm using right now (Haiku), I see the same problem -
-threaded and executeFile fails with `Operation not allowed', but
-threaded and runProcess does not fail.  I wish I understood this
better myself, but the problem appears to be something that the
runtime does after fork().  In a C program with multiple threads,
I get this error with a direct exec or a fork/exec, but not with a
fork/exec from the main thread.

With a -threaded Haskell program, +RTS -Nn actually does not make
any difference, unless there's another value for n that I should
have used.

Is there a way to suppress extra GHC runtime threads, when compiled
with -threaded?  I see three threads running, none of them spawned
by the application.  Where would this be documented?

thanks,
Donn Cave, d...@avvanta.com

 On Mon, May 17, 2010 at 9:41 AM, Thomas Schilling
 nomin...@googlemail.comwrote:

 Works fine on 10.6.3.  If you run with +RTS -N2, though, you'll get
 forking not supported with +RTS -Nn greater than 1

 The reason for this is that forking won't copy over the threads which
 means that the Haskell IO manager stops working (you'd have to somehow
 reinitialise the RTS while leaving heap and runtime stacks in tact --
 very tricky).

 I'm using http://hackage.haskell.org/package/process to run external
 processes.  I haven't had any problems with it.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] executeFile failing on macosx

2010-05-16 Thread David Powell
executeFile is failing for me on Mac OS X 10.5.8, with ghc 6.12.1 when
compiling with -threaded.  Compiling without -threaded, or running on
linux is fine.

When compiled with -threaded, the following snippet produces the error:
  testProg: /bin/echo: executeFile: failed (Operation not supported)

 import System.Posix.Process
 main = do

  forkProcess $ executeFile /bin/echo False [Ok] Nothing

Any suggestions for a work around for this would be appreciated.

Cheers,

-- 
David Powell
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] executeFile failing on macosx

2010-05-16 Thread Bulat Ziganshin
Hello David,

Sunday, May 16, 2010, 7:18:29 PM, you wrote:

 executeFile is failing for me on Mac OS X 10.5.8, with ghc 6.12.1
 when compiling with -threaded.  Compiling without -threaded, or running on 
 linux is fine. 
  forkProcess $ executeFile /bin/echo False [Ok] Nothing

afair, forkProcess and -threaded shouldn't work together on any Unix.
can you try forkIO or forkOS instead?



-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] executeFile failing on macosx

2010-05-16 Thread David Powell
On Mon, May 17, 2010 at 1:33 AM, Bulat Ziganshin
bulat.zigans...@gmail.comwrote:

 Hello David,

 Sunday, May 16, 2010, 7:18:29 PM, you wrote:

  executeFile is failing for me on Mac OS X 10.5.8, with ghc 6.12.1
  when compiling with -threaded.  Compiling without -threaded, or running
 on linux is fine.
   forkProcess $ executeFile /bin/echo False [Ok] Nothing

 afair, forkProcess and -threaded shouldn't work together on any Unix.
 can you try forkIO or forkOS instead?


Hi Bulat,

Both, forkIO and forkOS fail in the same way for me with -threaded.  I
believe this is because macosx requires the process to only have a single
thread when doing an execv(), which I thought was the purpose of
forkProcess?

Cheers,

-- David
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] executeFile failing on macosx

2010-05-16 Thread Thomas Schilling
Works fine on 10.6.3.  If you run with +RTS -N2, though, you'll get
forking not supported with +RTS -Nn greater than 1

The reason for this is that forking won't copy over the threads which
means that the Haskell IO manager stops working (you'd have to somehow
reinitialise the RTS while leaving heap and runtime stacks in tact --
very tricky).

I'm using http://hackage.haskell.org/package/process to run external
processes.  I haven't had any problems with it.

On 17 May 2010 00:06, David Powell da...@drp.id.au wrote:

 On Mon, May 17, 2010 at 1:33 AM, Bulat Ziganshin bulat.zigans...@gmail.com
 wrote:

 Hello David,

 Sunday, May 16, 2010, 7:18:29 PM, you wrote:

  executeFile is failing for me on Mac OS X 10.5.8, with ghc 6.12.1
  when compiling with -threaded.  Compiling without -threaded, or
  running on linux is fine.
   forkProcess $ executeFile /bin/echo False [Ok] Nothing

 afair, forkProcess and -threaded shouldn't work together on any Unix.
 can you try forkIO or forkOS instead?


 Hi Bulat,

 Both, forkIO and forkOS fail in the same way for me with -threaded.  I
 believe this is because macosx requires the process to only have a single
 thread when doing an execv(), which I thought was the purpose of
 forkProcess?

 Cheers,

 -- David

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe





-- 
Push the envelope.  Watch it bend.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] executeFile failing on macosx

2010-05-16 Thread David Powell
Indeed System.Process does work for me.  I had avoided it because it is a
little more awkward to use it when you want the actual PIDs.  I don't
understand why System.Process.runProcess works for me, but executeFile does
not.  I did find this issue (for python)
http://bugs.python.org/issue6800which I think is the same thing I'm
hitting and they also claim it is fixed
in macosx 10.6.

Anyway, I'll work with System.Process for now.  Thanks for your help.

-- David

On Mon, May 17, 2010 at 9:41 AM, Thomas Schilling
nomin...@googlemail.comwrote:

 Works fine on 10.6.3.  If you run with +RTS -N2, though, you'll get
 forking not supported with +RTS -Nn greater than 1

 The reason for this is that forking won't copy over the threads which
 means that the Haskell IO manager stops working (you'd have to somehow
 reinitialise the RTS while leaving heap and runtime stacks in tact --
 very tricky).

 I'm using http://hackage.haskell.org/package/process to run external
 processes.  I haven't had any problems with it.

 On 17 May 2010 00:06, David Powell da...@drp.id.au wrote:
 
  On Mon, May 17, 2010 at 1:33 AM, Bulat Ziganshin 
 bulat.zigans...@gmail.com
  wrote:
 
  Hello David,
 
  Sunday, May 16, 2010, 7:18:29 PM, you wrote:
 
   executeFile is failing for me on Mac OS X 10.5.8, with ghc 6.12.1
   when compiling with -threaded.  Compiling without -threaded, or
   running on linux is fine.
forkProcess $ executeFile /bin/echo False [Ok] Nothing
 
  afair, forkProcess and -threaded shouldn't work together on any Unix.
  can you try forkIO or forkOS instead?
 
 
  Hi Bulat,
 
  Both, forkIO and forkOS fail in the same way for me with -threaded.  I
  believe this is because macosx requires the process to only have a single
  thread when doing an execv(), which I thought was the purpose of
  forkProcess?
 
  Cheers,
 
  -- David
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 



 --
 Push the envelope.  Watch it bend.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe