I have a daemon which loads DBI (DBD::mysql) and then forks child processes. I’d like to prevent the DBI module from being in memory in the forked child processes.
So something like this:
#!/usr/bin/perl
use DBI;
my $dbh = DBI->connect(db_info);
my $pid = fork();
if($pid){
# The forked process here should not have DBI loaded
}
Thanks for the help!
Loading a module is to execute it like a script. There’s absolutely no difference between a module and a script to Perl. To unload a module, one would need to undo the effects of running it. That can’t be done mechanically, and it’s not feasible to do manually.
The simplest solution would to be to have the child
execsomething. It could even be the script you are already running.The child can be given access to the socket by binding it to the child’s fd 0 (stdin) and fd 1 (stdout).