Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4094804
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:47:47+00:00 2026-05-20T19:47:47+00:00

According to the Nginx documentation : If you need to replace nginx binary with

  • 0

According to the Nginx documentation:

If you need to replace nginx binary
with a new one (when upgrading to a
new version or adding/removing server
modules), you can do it without any
service downtime – no incoming
requests will be lost.

My coworker and I were trying to figure out: how does that work?. We know (we think) that:

  • Only one process can be listening on port 80 at a time
  • Nginx creates a socket and connects it to port 80
  • A parent process and any of its children can all bind to the same socket, which is how Nginx can have multiple worker children responding to requests

We also did some experiments with Nginx, like this:

  • Send a kill -USR2 to the current master process
  • Repeatedly run ps -ef | grep unicorn to see any unicorn processes, with their own pids and their parent pids
  • Observe that the new master process is, at first, a child of the old master process, but when the old master process is gone, the new master process has a ppid of 1.

So apparently the new master process can listen to the same socket as the old one while they’re both running, because at that time, the new master is a child of the old master. But somehow the new master process can then become… um… nobody’s child?

I assume this is standard Unix stuff, but my understanding of processes and ports and sockets is pretty darn fuzzy. Can anybody explain this in better detail? Are any of our assumptions wrong? And is there a book I can read to really grok this stuff?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T19:47:48+00:00Added an answer on May 20, 2026 at 7:47 pm

    For specifics: http://www.csc.villanova.edu/~mdamian/Sockets/TcpSockets.htm describes the C library for TCP sockets.

    I think the key is that after a process forks while holding a socket file descriptor, the parent and child are both able to call accept() on it.

    So here’s the flow. Nginx, started normally:

    1. Calls socket() and bind() and listen() to set up a socket, referenced by a file descriptor (integer).
    2. Starts a thread that calls accept() on the file descriptor in a loop to handle incoming connections.

    Then Nginx forks. The parent keeps running as usual, but the child immediately execs the new binary. exec() wipes out the old program, memory, and running threads, but inherits open file descriptors: see http://linux.die.net/man/2/execve. I suspect the exec() call passes the number of the open file descriptor as a command line parameter.

    The child, started as part of an upgrade:

    1. Reads the open file descriptor’s number from the command line.
    2. Starts a thread that calls accept() on the file descriptor in a loop to handle incoming connections.
    3. Tells the parent to drain (stop accept()ing, and finish existing connections), and to die.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to the feedparser documentation , I can turn an RSS feed into a
According to a post at the very end of this thread you can replace
According to the MSDN documentation , transactional NTFS doesn't seem to allow one to
According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to
According to what I have found so far, I can use the following code:
According to the answers to this question, I cannot embed a file version in
I've got a PHP-fpm setup on nginx setup according to this article: http://interfacelab.com/nginx-php-fpm-apc-awesome/ PHP
According to MSDN, System.Int32 is immutable, and its members always return new instances. Some
According to this SDK guide , unit-testing a Library project can be achieved by
According to the documentation : Fills the internal buffer with the specified number of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.