create_open: parallelize directory vivification
[MogileFS-Server.git] / lib / Mogstored / ChildProcess.pm
blobd12ac7055cde88cd6864b838a89e45db162def1f
1 package Mogstored::ChildProcess;
2 use strict;
4 sub run {
5 my $class = shift;
6 die "run not implemented for $class\n";
9 sub pre_exec_init {
10 my $class = shift;
11 # override to setup environment ...
14 sub exec {
15 my $class = shift;
16 if (_running_under_par()) {
17 # then we can't exec, as we'll lose magic @INC
18 # ghetto:
19 #for (3..100) { POSIX::close($_); }
20 my $rv = eval "use $class; 1" or die "Failed to load $class: $@\n";
21 $class->run;
22 } else {
23 exec $^X, "-M$class", "-e", "$class->run;";
25 die "$class run loop ended!\n";
28 sub _running_under_par {
29 # not the best test in the world, but works.
30 return (grep { ref $_ eq "CODE" } @INC) ? 1 : 0;