Skip to content

Instantly share code, notes, and snippets.

@dfaerch
dfaerch / forkmanager_example.pl
Created Mar 3, 2016
Example of Parallel::ForkManager, with setuid() and with returning data to parent, using /dev/shm for temp storage
View forkmanager_example.pl
#!/usr/bin/perl
use strict;
use warnings;
use Parallel::ForkManager 1.7.6;
use Data::Dumper;
use POSIX qw(setuid setgid);
use File::Temp;
# We make a temp tmp dir in memory (/dev/shm/) instead of built in /tmp/ (for speedy access)
my $tmpdir = mkdtemp("/dev/shm/$0.XXXXXXXXX") ;