Brandon S. Allbery KF8NH
allbery at ece.cmu.edu
Wed May 6 16:57:29 EDT 2009
-----BEGIN PGP SIGNED MESSAGE-----
On May 6, 2009, at 16:39 , brian at lorf.org wrote:
> On Wednesday, 06.05.09 at 16:25, Brandon S. Allbery KF8NH wrote:
>> No. What it means is that, if the child will continue to run in the
>> same Haskell program after forkProcess-ing, any open Handles won't
>> work right. You could fix this with handleToFd and fdToHandle, I
>> suspect, but it's irrelevant because you're going to executeFile
> I forkProcess. The parent gets the PID. The child does
> then executeFile, which is done with one of the execvs, which replaces
> the child process with the program I'm trying to communicate with.
> So now the program is resource limited and will probably quit if it
> takes too much CPU time. But the parent just has the child's PID.
> How is
> it communicating with the child?
Create pipes (System.Posix.IO.createPipe) before forkProcess. In the
child, close stdin/stdout/stderr handles (which are unusable anyway)
as appropriate and dupTo the write pipes to stdout and stderr and read
pipe to stdin (again, as appropriate; remember that doing both stdin
and stdout means you need to be careful to avoid data starvation
In the parent you use fdToHandle to turn the other end of each pipe
into a Handle that you can use as normal.
You might want to study how to do this in C first, as the System.Posix
calls are simple wrappers around the standard POSIX library routines.
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university KF8NH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (Darwin)
-----END PGP SIGNATURE-----
More information about the Haskell-Cafe