Skip to content

Instantly share code, notes, and snippets.

@olegwtf
Created March 19, 2012 06:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olegwtf/2098125 to your computer and use it in GitHub Desktop.
Save olegwtf/2098125 to your computer and use it in GitHub Desktop.
Mojolicious fork
use Mojolicious::Lite;
use POSIX;
get '/' => sub {
my $child = fork();
unless (defined $child) {
die "fork(): $!";
}
elsif ($child == 0) {
POSIX::setsid();
open (STDIN, "</dev/null");
open (STDOUT, ">/dev/null");
open (STDERR, ">&STDOUT");
exec 'sleep', '130';
exit;
}
shift->render(text => 'Hello world!');
};
app->start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment