From p.dalgaard at biostat.ku.dk  Fri Feb 11 14:32:20 2005
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Fri Feb 11 14:37:07 2005
Subject: [Rd] Pipe / Fork: Partial Solution / Providing Connections from C?
In-Reply-To: <20050211122739.GA1442@jtkpc.cmp.uea.ac.uk>
References: <20050201135305.GA29528@jtkpc.cmp.uea.ac.uk>
	<Pine.LNX.4.61.0502011335290.15311@gannet.stats>
	<20050201195017.GC30798@jtkpc.cmp.uea.ac.uk>
	<20050211122739.GA1442@jtkpc.cmp.uea.ac.uk>
Message-ID: <x2acqb2pej.fsf@biostat.ku.dk>

"Jan T. Kim" <jtk@cmp.uea.ac.uk> writes:

> > Well, that is probably reasonably easy, but (not the least due to that
> > fact) I'm still surprised that it has not been done already. I can hardly
> > imagine that I'm the first one to want to use some external utility from
> > an R program in this way.
> > 
> > So, what do you R-devel folks do in this case, and what would you
> > recommend?
> 
> I'm still curious about this one. If there really is no way of running
> stuff through external filter processes in R, I'd volunteer to add
> that.
> 
> Best regards & thanks in advance, Jan

If you know how, please do. I have a suspicion it might not be as easy
as it sounds because of the producer/consumer aspects. Notice, though,
that in most cases you can get by with system() or pipe() and a
temporary file for either the input or the output.

I remember speculating about these matters when I was first introduced
to pipes in C: They'd show you how to open a pipe for reading and how
to do it for writing, but not how to do both with the same process.
Took me a while to realize that there is a nontrivial deadlock issue
if you try to write to a process that itself is blocked trying to
write its output. Now that is of course not to say that it cannot be
done with clever multiplexing and buffering techniques -- or
multithreading, except that R isn't threaded.

BTW, we met in Heidelberg at the ECMBM ages ago, didn't we? 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907


[Rd] Pipe / Fork: Partial Solution / Providing Connections from C?
Peter Dalgaard