Re: Fundamental pipe questions



"Lost Sheep Of the Porn" <cdalten@xxxxxxxxx> wrote:

Yes, the strange characters were introduced by my browser.

Clearly they are introduced in your posting software, not your browsing
software. Please try to fix that, or people will be less likely to respond
to you.


If both these constructs are the same, then why does perlipc rattle on
about using |- for safe pipe opens. I think the following from perlipc
comes to mind.

And here=E2=80=99s a safe pipe open for writing:

# add error processing as above
$pid =3D open(KID_TO_WRITE, "|-");

Notice that lack of any third (or more) arguments in that pipe open,
and the lack of program name in the 2nd argument.

$SIG{PIPE} =3D sub { die "whoops, $program pipe broke" };

if ($pid) { # parent
for (@data) {
print KID_TO_WRITE;
}
close(KID_TO_WRITE) || warn "kid exited $?";

} else { # child
($EUID, $EGID) =3D ($UID, $GID);

See here where it mucks around with $EUID? If you used either the
two argument open which contained the command name and all of its arguments
in the 2nd argument, or the 3 or more argument form, then you would not
have an opportunity to do this before the $program got executed. That is
the main thing that makes this safer than the alternative. The second
thing is that by using the multi-argument form of exec, you prevent the
shell from trying to interpret the arguments (this one you could also do,
on sufficiently modern Perls, by using the more than 3 argument pipe open).


exec($program, @options, @args)
|| die "can=E2=80=99t exec program: $!";
# NOTREACHED
}

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
.