Hello folks,
I am writing a web based interface to gpg and am using IPC::Open3 and
IO::Select to manage STDIN, STDOUT and STDERR handles. But, I can not
get stdin to work properly. Here is my code:
$gpgCommand = "gpg --homedir $home --no-default-keyring
--secret-keyring rasoul.asc --decrypt $encryptedFile";
print "$gpgCommand\n";
$pid = open3(*FIN,*FOUT,*FERR,"$gpgCommand");
$SIG{CHLD} = sub { print "REAPER: status $? on $pid\n" if
waitpid($pid,0) > 0 };
$selector = IO::Select->new();
$selector->add(*FOUT,*FERR);
while (@handles = $selector->handles)
{
foreach my $fh (@handles)
{
if (fileno($fh) == fileno(FERR))
{
print "STDERR: ", scalar <FERR>
}
elsif (fileno($fh) == fileno(FOUT))
{
@out = <FOUT>;
}
elsif ((fileno($fh) == fileno(FIN))
{
print FIN "$passPhrase\n";
}
$selector->remove($fh) if eof($fh);
}
}
$pf->close;
close FERR;
close FIN;
close FOUT;
I am using perl 5.053 and Apache/1.3.14 Ben-SSL/1.42 (Unix) PHP/4.0.3pl1
mod_perl/1.24_01.
Can anyone see what am I doing wrong?
Thanks in advance
-r