<div dir="ltr">Hi.<div><br></div><div>It's easy to reproduce such problem that</div><div>the master/worker process are running without the pid file.</div><div><br></div><div><span style="font-size:14px">Step by step:</span></div><div><span style="font-size:14px"><br></span><div>1. Start master process.</div><div>    > ./objs/nginx   </div><div>    nginx.pid successfully create with content (23234)</div><div><br></div><div>2. Create an active connection, purpose for prevent previous master exit.</div><div>   > telnet 127.1 80</div><div><br></div><div>3. Quit the previous master, and it still alive for a while.</div><div>   > kill -QUIT 23234</div><div><br></div><div>4. Start new master process 23361, and the content of nginx.pid is changed to 23361</div><div>   > ./objs/nginx</div><div>   It successfully start because of the listening port is closed by the step 3.<br></div><div><br></div><div>5. Wait for a while, and the nginx.pid is deleted while the old master process (23234) completely quit.</div></div><div><br></div><div>Now the master process (23361) is running without nginx.pid.</div><div><br></div><div>So, there are two key points:</div><div>1. Master start, I think there is not problem.</div><div>2. Master Exit, is it better to add the pid check with the pid file?</div><div><br></div><div>Anyway, I think we should guarantee the pid file associates with the running process.</div><div><br></div><div>src/os/unix/ngx_process_cycle.c</div><div><div><br></div><div>+static ngx_int_t</div><div>+ngx_is_same_pid(ngx_cycle_t *cycle)</div><div>+{</div><div>+        return read_pid_from_pidfile. // TODO</div><div>+}</div><div><br></div><div>static void</div><div>ngx_master_process_exit(ngx_cycle_t *cycle)</div><div>{</div><div>    ngx_uint_t  i;</div><div><br></div><div>-   ngx_delete_pidfile(cycle);<br></div><div>+  if (ngx_is_same_pid(cycle)) {</div></div><div>+        ngx_delete_pidfile(cycle);</div><div>+</div><div>+  } else {</div><div>+        ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "blalala...");</div><div>+ }</div><div><br></div><div>Thanks.</div><div>B.R.</div></div>