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 7407423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:43:08+00:00 2026-05-29T05:43:08+00:00

I have a parent which when it starts, kicks off a thread that creates

  • 0

I have a parent which when it starts, kicks off a thread that creates an instance of TCP Server that listens on port X. After this, the parent starts forking off child processes (which do few things and exit). Note that these child processes inherit fds from parent and hence end up listening on port X.

The parent program has a handler for requests coming in on port X but the child process has no such handler (it is a os.execv()-ed C++ program)

I know that child process could close all fds, in which case the above situation will not arise. What happens to a incoming request on port X? How is it processed?

Here’s what i have observed so far…
The tcp request handler in the parents executes commands.getstatusoutput(..) when it receives a request. Most of the times, it behaves as expected (or the way i expected) – execution of the above command without any errors …but occasionally i get

File "/home/y/lib/python2.7/commands.py", line 61, in getstatusoutput
    sts = pipe.close()
IOError: [Errno 10] No child processes
  • 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-29T05:43:09+00:00Added an answer on May 29, 2026 at 5:43 am

    At the operating-system level, there shouldn’t be any problem with this. This is essentially the way that pre-forked servers work:

    1. Create socket in main thread
    2. Bind the socket to an address
    3. Call listen() to put the socket into listen mode — at this point, any connection requests will be accepted and queued by the OS
    4. Fork a bunch of children, each of which inherits the open socket
    5. Then the child processes each call accept(), which blocks until there is a connection for them to handle.

    If a child chooses not to call accept() on the listening socket, (as your exec’ed proccess won’t) then there shouldn’t be any issues for that process, or for the ones who are still accepting connections.

    The only complication that I can see is that the socket can’t be closed — in order for the operating system to actually close it, all processes with a reference to it have to call close() on it, bringing its open descriptor count down to zero.

    It is probably best, in your case, if that behaviour is interfering with the rest of your application, to close the listening socket in the child — after you fork, but before you call exec.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a parent thread (non-UI) which creates some child threads to do some
I have a parent thread (non-UI) which creates some child threads to do some
I have a parent grid that contains multiple row definitions, all of which have
Imagine I have a process that starts several child processes. The parent needs to
I have a parent object which has a one to many relationship with an
I have a parent class which contains a child object. I am using set
I have this huge domain object(say parent) which contains other domain objects. It takes
I have a parent table called 'Website' which holds records about websites. I have
Say I have an parent entity, each of which have a number of children.
I have a MustInherit Parent class with two Child classes which Inherit from the

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.