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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:54:47+00:00 2026-06-11T16:54:47+00:00

Background I am writing a shared library in C, dynamically linked with LD_PRELOAD ,

  • 0

Background

I am writing a shared library in C, dynamically linked with LD_PRELOAD, that is meant to intercept and override network calls from the application preloading it, such as socket(), connect(), recv(), send(), etc.

In the init of the library I launch a thread with pthread_create(). This thread polls some kernel memory, which is mapped to user space.

The library is meant to be generic enough to deal with – but not limited to – networking benchmark applications such as netperf, iperf, sockperf.

My issue

Everything works fine, life is sweet in most of the cases except one. Deamonized applications. For instance, if I launch netserver (the server side of the netperf benchmarking application) as a deamon, i.e. without the -D parameter, one of the first things the application does is call fork(). On fork, the parent is closed using exit(EXIT_SUCCESS) and the child listens for connections. The fact that the parent exits kills my polling thread.

So what I’d like to achieve is have the child spawn a new polling thread if the parent has gone. I can intercept and override the fork() call but fundamentally, how can I have the child know whether the parent has gone or not? I can’t take any assumption because the library has to be generic.

Thanks.

  • 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-06-11T16:54:49+00:00Added an answer on June 11, 2026 at 4:54 pm

    You can poll periodically getppid() function. As soon as it starts to return ‘1’ (the id of init process) – your parent is dead.

    Update

    excerpt from ‘man pthread_create’:

    The new thread terminates in one of the following ways: …

    • Any of the threads in the process calls exit(3), or the main thread
      performs a return from main(). This causes the termination of all
      threads in the process.

    So, if your thread is created by the netserver process that calls exit – yes this thread will be terminated

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

Sidebar

Related Questions

Background I'm writing an web application so I can control an Ubuntu Server from
Background: I'm writing a data provider that SSAS will use to get data from
Background: I'm writing a Java server application that needs to perform basic interactions with
Background I'm writing a graphing library for an android application (yes yes, I know
Background: I'm writing a 'standard' (nothing special) web application in Ruby (not Rails) and
Background I am writing a program that targets several different phones, including the iPhone.
Background I am writing a survey that is going to a large audience. It
Background : I'm currently writing a greasemonkey script that embeds/modifies a specific page's html.
(I'm Coming from a C# background writing iPhone apps with MonoTouch) I have a
Quick background: writing a module. One of my objects has methods that may or

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.