M
Matthew Braid
Hi all,
I'm using GnuPG::Interface to verify some PGP signed data, and for the
most part it all seems to be working nicely.
I have come across a small problem though. Sometimes (not always, which
makes this nicely annoying) the function I use to read through the
output blocks indefinitely.
The segment of code that causes the problem is:
# $fh is a filehandle passed in to the function -
# its an IO::Handle object that's been used as the
# stderr handle to GnuPG::Interface::verify
my ($buffer, $ok) = ('', undef);
while (1) {
if (not sysread($fh, $buffer, 1024, length($buffer)) {
last if not length $buffer;
$ok = [1, $1] if $buffer =~ PGP_SIGOK;
last;
}
# Do some stuff with buffer to look for individual lines...
}
This _almost_ always works fine. Rarely, that sysread hangs. If i'm
looking at the process table at the time and I kill off the gpg process,
everything trucks along as it should.
Is there a way to fix this. Maybe a different method for reading in the
data? I'm guessing that the problem is that sometimes gpg doesn't spit
out a newline at the end of its stderr messages, but I can't find any
obvious differences between messages that work and those that block.
MB
I'm using GnuPG::Interface to verify some PGP signed data, and for the
most part it all seems to be working nicely.
I have come across a small problem though. Sometimes (not always, which
makes this nicely annoying) the function I use to read through the
output blocks indefinitely.
The segment of code that causes the problem is:
# $fh is a filehandle passed in to the function -
# its an IO::Handle object that's been used as the
# stderr handle to GnuPG::Interface::verify
my ($buffer, $ok) = ('', undef);
while (1) {
if (not sysread($fh, $buffer, 1024, length($buffer)) {
last if not length $buffer;
$ok = [1, $1] if $buffer =~ PGP_SIGOK;
last;
}
# Do some stuff with buffer to look for individual lines...
}
This _almost_ always works fine. Rarely, that sysread hangs. If i'm
looking at the process table at the time and I kill off the gpg process,
everything trucks along as it should.
Is there a way to fix this. Maybe a different method for reading in the
data? I'm guessing that the problem is that sometimes gpg doesn't spit
out a newline at the end of its stderr messages, but I can't find any
obvious differences between messages that work and those that block.
MB