[Wellington-pm] pass-through pipe?

Richard Hector richard at walnut.gen.nz
Sat Jul 17 23:13:13 PDT 2010


On Sun, 2010-07-18 at 17:06 +1200, Lenz Gschwendtner wrote:
> you mean something other than one process prints to STDOUT and the other one reading from STDIN ... 
> 
> not sure i get your question right but if you need something other than the normal stuff then you might be after a FIFO buffer? shared memory? what is the use case? probably that helps :-)

The use case is encrypting postgresql backups:

system "pg_dump --cluster $cluster --dbname $dbname ... | gpg
--options ... --encrypt";

Currently I'm doing that in one 'system' line as described, but that
fires up a shell, which shouldn't be necessary?

I think if I was doing it in C, I'd call pipe(2), which would return 2
file handles (one reader and one writer).

I'd then fork once for pg_dump, and substitute the writer filehandle for
stdout, then exec pg_dump.

I'd then fork again for gpg, and substitute the reader filehandle for
stdin, then exec gpg.

I haven't tried any of that, though - I'm guessing as to what might
happen when a shell executes a pipeline like that. I could go read the
bash source, I guess ...

Does that make sense?

Thanks,
Richard




More information about the Wellington-pm mailing list