[dancer-users] How can a fork+system() Dancer app not create zombie processes?

Shlomi Fish shlomif at shlomifish.org
Mon Apr 3 11:22:16 BST 2017


Hi Andy!

On Mon, 3 Apr 2017 09:15:37 +0100
Andrew Beverley <andy at andybev.com> wrote:

> On Mon, 3 Apr 2017 11:01:23 +0300 Shlomi Fish wrote:
> > When running a simple and reduced Dancer 1 application which forks
> > and runs perldoc -f system , I am getting many zombie processes after
> > making requests.  
> 
> Forking a web app is not as simple as it first seems. 

Do you mean forking any web app or just Dancer apps? 

> You need to take
> an approach like the following (hopefully the comments will explain
> without me regurgitating here, but feel free to ask for clarification):
> 
> https://github.com/ctrlo/GADS/blob/cb8c9478dee8eac1f40a44486634173bed8d666d/lib/GADS/Record.pm#L1068
> 

I don't understand the code there in part because it uses too many custom APIs
like "guard"s and "try". Furthermore, the licence is the AGPLv3 which cannot be
used inside my MIT Expat code.

If someone can provide a simple interface to spawn a background child process
in Dancer, I will appreciate it. Something like:

use Dancer::Plugin::SpawnProc;

# Inside the handler:
dancer_spawn_proc (sub {
	# I am the child process.
	system("mpv", 'no-exist.webm');
	exit(0);
});

==========

Regards,

	Shlomi Fish

> The key point being that you need to fork both a child and a
> grand-child in order to correctly reap all the forked processes.
> 
> Andy



-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
List of Text Editors and IDEs - http://shlom.in/IDEs

You gotta go out there, believe in the ball, and throw yourself.
    — The Wise Janitor in http://en.wikipedia.org/wiki/Not_another_teen_movie

Please reply to list if it's a mailing list post - http://shlom.in/reply .


More information about the dancer-users mailing list