+
+ # Fork a child process to handle the aggregation.
+ # The parent process will then handle building the result.
+ # This avoids messy code to clear state accumulated while
+ # aggregating.
+ defined(my $pid = fork) or error("Can't fork: $!");
+ if (! $pid) {
+ loadstate();
+ IkiWiki::loadindex();
+ aggregate();
+ expire();
+ savestate();
+ exit 0;
+ }
+ waitpid($pid,0);
+ if ($?) {
+ error "aggregation failed with code $?";
+ }
+