﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
900	"Nginx won't daemonise if ""NGINX"" environment variable is set"	davidjb		"On non-Win32 platforms, I've found that Nginx won't daemonise if an environment variable with the name `NGINX` (any value) is present in the parent environment.

I had written the following:

{{{
export NGINX=1.9.11
wget -O - http://nginx.org/download/nginx-${NGINX}.tar.gz | tar -xzf -
cd nginx-${NGINX}
./configure --with-debug && make && make install
nginx -c ~/nginx.conf -p ~
}}}

and discovered that the final command wouldn't daemonise Nginx, even though `daemon on` was explicitly present in the configuration.  After trial-and-error, I found the cause was the environment variable and I had to consult Nginx's source to discover why this was happening.  Nginx believes it is working to inherit sockets (https://github.com/nginx/nginx/blob/master/src/core/nginx.c#L444), which, after the `NGINX` variable is read from the environment, flags `ngx_inherited = 1`.  The invocation for daemonising is at https://github.com/nginx/nginx/blob/master/src/core/nginx.c#L332, which checks for `ngx_inherited` and then thus skips over daemonising.

I now know the errors logs *do* output a logging message about this:

{{{
2016/02/12 06:52:17 [notice] 8624#0: using inherited sockets from ""1.9.11""
}}}

but as I had debugging messages enabled, this non-error wasn't obvious amongst the other logged messages.

So, to avoid this pitfall, can the environment variable be made more specific (such as `__NGINX_INHERITED_SOCKETS`)?  Perhaps an error could also be raised/logged if value supplied to the environment variable are incorrectly formatted, and this behaviour be documented so others avoid this same pitfall."	defect	closed	minor		documentation	1.9.x	fixed			"Linux localhost.localdomain 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
"	"nginx version: nginx/1.9.11
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
configure arguments: --with-debug
"
