Lots of djb programs and related/similar utilities (e.g. sslclient) have interfaces that want data written to or read from specific file descriptors. (With sslclient: "sslclient runs prog, with file descriptors 6 and 7 reading from and writing to a child process").
Maybe I'm interpreting things incorrectly, but is there a way to open a file on a specific fd in Perl? I tried the following with open, but it seems to fail if the fd's not already open:
$ perl -lwe 'open STDOUT, ">&=6" or die ">&=6: $!"'
>&=6: Bad file descriptor at -e line 1.
$ perl -lwe 'open STDOUT, ">&=6" or die ">&=6: $!"' 6>/dev/null
The goal is to provide a similar interface, like:
# Don't use this - DOESN'T WORK
open my $to_child, ">&=6" or die ">&=6: $!";
open my $from_child, "<&=7" or die "<&=7: $!";
die "fork:$!" if not defined(my $pid = fork);
if ($pid) {
print $to_child "data for child\n";
my $ret = <$from_child>;
} else {
exec { "sub-program" } "sub-program", @args;
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|