summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-04-20 15:51:26 +0000
committerfukachan <fukachan>2002-04-20 15:51:26 +0000
commita97981da3c6ed762a323ea2bef2935d51180ebba (patch)
tree59c2104c628240250311fdff81a96ce1f1244f89
parent46156e66b3ed61a162bd32207ec137d141e0af47 (diff)
downloadfml8-a97981da3c6ed762a323ea2bef2935d51180ebba.tar.gz
fml8-a97981da3c6ed762a323ea2bef2935d51180ebba.tar.bz2
fml8-a97981da3c6ed762a323ea2bef2935d51180ebba.zip
for () { fork() && call htmlify_file() }
-rw-r--r--fml/lib/Mail/Message/ToHTML.pm30
1 files changed, 25 insertions, 5 deletions
diff --git a/fml/lib/Mail/Message/ToHTML.pm b/fml/lib/Mail/Message/ToHTML.pm
index 5a559060..ac907476 100644
--- a/fml/lib/Mail/Message/ToHTML.pm
+++ b/fml/lib/Mail/Message/ToHTML.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: ToHTML.pm,v 1.13 2002/04/19 05:22:01 fukachan Exp $
+# $FML: ToHTML.pm,v 1.14 2002/04/19 16:21:54 fukachan Exp $
#
package Mail::Message::ToHTML;
@@ -19,7 +19,7 @@ my $debug = 0;
my $URL =
"<A HREF=\"http://www.fml.org/software/\">Mail::Message::ToHTML</A>";
-my $version = q$FML: ToHTML.pm,v 1.13 2002/04/19 05:22:01 fukachan Exp $;
+my $version = q$FML: ToHTML.pm,v 1.14 2002/04/19 16:21:54 fukachan Exp $;
if ($version =~ /,v\s+([\d\.]+)\s+/) {
$version = "$URL $1";
}
@@ -2467,8 +2467,9 @@ sub htmlify_file
sub htmlify_dir
{
my ($src_dir, $args) = @_;
- my $dst_dir = $args->{ directory };
- my $max = 0;
+ my $dst_dir = $args->{ directory };
+ my $max = 0;
+ my $has_fork = 1; # ok on unix and perl>5.6 on wine32.
print STDERR "src = $src_dir\ndst = $dst_dir\n" if $debug;
@@ -2485,7 +2486,26 @@ sub htmlify_dir
for my $id ( 1 .. $max ) {
use File::Spec;
my $file = File::Spec->catfile($src_dir, $id);
- htmlify_file($file, { directory => $dst_dir });
+
+ unless ( $has_fork ) {
+ htmlify_file($file, { directory => $dst_dir });
+ }
+ else {
+ my $pid = fork();
+ if ($pid < 0) {
+ croak("cannot fork");
+ }
+ elsif ($pid == 0) {
+ htmlify_file($file, { directory => $dst_dir });
+ exit 0;
+ }
+
+ # parent
+ my $dying;
+ while (($dying = wait()) != -1 && ($dying != $pid) ){
+ ;
+ }
+ }
}
}