http://qs1969.pair.com?node_id=659926


in reply to Re: Open a file on a specific file descriptor?
in thread Open a file on a specific file descriptor?

I don't understand if you're trying to use those programs or to recreate similar ones.

The attempt was a little of both, but I should have specified that I was trying to provide an sshclient-like interface for a qmail filtering program, since (as you mentioned) running a Perl program as sshclient's child is pretty easy.

I'd used sshclient in the past, and even though I often mix up which fd is read and which is write does what (different djb/djb-like util's use different fd's for different things), I like the nice, generic, cross-language interface. It fits nicely with both "Do one thing, and do it well" and "Everything's a pipe". I wondered how easy it'd be to provide that interface in Perl.

The idea was that I would provide the filtering program (child) fd's 0,1,4,5,6,7 for message-in, message-out, header-in, header-out, body-in, and body-out. If any of the '-out's was the same as its '-in' or was empty, the original would be used. And, either message-out or (header-out + body-out) would be used, depending on what the filter program changed.

Since this isn't easy to do, I'm probably going to use an option flag to specify which one of 'message', 'headers', or 'body' the filter wants to have and just use STDIN + STDOUT.

Thanks

Update: clarified my confusion re: djb{|-esque} tools' use of fd's