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

  • Home
  • SEARCH
  • 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 6224165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:37:27+00:00 2026-05-24T08:37:27+00:00

I have a sample application of a SIP server listening on both tcp and

  • 0

I have a sample application of a SIP server listening on both tcp and udp ports 5060.
At some point in the code, I do a system(“pppd file /etc/ppp/myoptions &”);

After this if I do a netstat -apn, It shows me that ports 5060 are also opened for pppd!
Is there any method to avoid this? Is this standard behaviour of the system function in Linux?

Thanks,
Elison

  • 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-24T08:37:28+00:00Added an answer on May 24, 2026 at 8:37 am

    Yes, by default whenever you fork a process (which system does), the child inherits all the parent’s file descriptors. If the child doesn’t need those descriptors, it SHOULD close them. The way to do this with system (or any other method that does a fork+exec) is to set the FD_CLOEXEC flag on all file descriptors that shouldn’t be used by the children of you process. This will cause them to be closed automatically whenever any child execs some other program.

    In general, ANY TIME your program opens ANY KIND of file descriptor that will live for an extended period of time (such as a listen socket in your example), and which should not be shared with children, you should do

    fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
    

    on the file descriptor.


    As of the 2016? revision of POSIX.1, you can use the SOCK_CLOEXEC flag or’d into the type of the socket to get this behavior automatically when you create the socket:

    listenfd = socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0);
    bind(listenfd, ...
    listen(listemfd, ...
    

    which guarentees it will be closed properly even if some other simultaneously running thread does a system or fork+exec call. Fortunately, this flag has been supported for awhile on Linux and BSD unixes (but not OSX, unfortunately).

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

Sidebar

Related Questions

I have a sample TCP client and server application that I want to run
I have a little sample application I was working on trying to get some
I want to have sample application on phoneGap for iphone. i had done some
Hello i have created a sample application in android using eclipse IDE my code
Hi My web server is Apache.I have created a sample application in my local
I have created a sample application suing Application cache, My some files are located
Visual Studio 2005 C++ Windows XP Pro I have a sample application that I
I have prepared one sample application.When application install in devices download the file from
I have seen the sample application of iPhone MP-movie player - controller. They have
I have made a sample application which constructs a filter graph to capture audio

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.