> This works flawlessly on not all that large files; but when I tried it
on a 
> file over 1M, the whole process hangs at "print WRITER $text;". I know
the docs 
> talk about unix buffering and all, but I thought the output of spamc
is 
> supposed to be unbuffered?

actually, 1M is not the level where this would bomb... try a 256k file,
since spamc runs with -s 256000 if no -s is specified.

> Does anyone have any idea why it would hang altogether?

spamd is expecting an EOF to terminate the input from WRITER, but never
gets it since it's buffer is 256k and you are sending > 256k.

doing this makes it work....

use FileHandle;
use IPC::Open2;

my $bytes = shift;
if (!defined $bytes) { $bytes = "1024"; }

my $text = "\n\n";
my $text .= "a" x $bytes;
my $length = length($text);

print "Running /usr/bin/spamc -s $length -f\n";

$pid = open2 (*READER, *WRITER, "/usr/bin/spamc -s $length -f");
print WRITER $text;
close (WRITER);
$body .= $_ while (<READER>);
close (READER);

###########################

[EMAIL PROTECTED] /]# time perl test.pl 280000
Running /usr/bin/spamc -s 280000 -f

real    0m2.271s
user    0m0.029s
sys     0m0.010s

without the -s $length switch, it will sit there forever.... see 

[EMAIL PROTECTED] /]# time strace perl test.pl 280000
write(4, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"..., 278528
 <unfinished ...>

real    0m8.719s
user    0m0.014s
sys     0m0.014s

i waited 8.7 seconds and it never completed, where the same amount of
bytes only takes 2.2 seconds when you pass the -s $length to spamc.

are you doing this to keep it in memory and prevent disk writes?  
you should probably define a limit on the max file size you will pass to
spamc, and then check $length against that size, and if it's larger,
skip it.  either that or recode the way spamc handles it's STDIN.

dallas


-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to