Strange behavior with custom module and http proxy

Brian Bruns brian at bruns.com
Mon Dec 21 20:02:39 MSK 2009


Hi Piotr,

The (grand)child process does some things asynchronously from the
module and I'm basically using the double fork to know when the
grandchild is up and running (when execv() returns, I know its
initialized and running).  I then make a unix socket connection to it
and pass some data back and forth.  The (grand)child SIGALRM's and
exits after a timeout period (60 seconds) unless it's reattached to
and reused.  Curiously, if I bring up the child manually (nginx module
not doing the fork/exec) then everything works fine.  Also if a second
nginx worker attaches subsequently, it works.  It is only the act of
the fork which seems to invoke the problem.  It's almost as if nginx
is doing a wait() for the child before closing the request, although I
know the child has been reaped earlier and the grandchild is now a
child of init.

Like I said, I only noticed the behavior when using http proxy
caching, so the problem has existed for me all along without my being
aware of it.

Brian

2009/12/21 Piotr Sikora <piotr.sikora at frickle.com>:
> Hi Brian,
> it's hard to tell what goes wrong just from your description, but could you
> explain what's the reason behind double-fork() & reparenting child process?
>
> I've recently made a module (to be released *soon*) which also fork()s and I
> didn't notice such behavior.
>
> Best regards,
> Piotr Sikora < piotr.sikora at frickle.com >
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>



More information about the nginx mailing list