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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:04:25+00:00 2026-05-20T23:04:25+00:00

I found the answer in Managing Signal Handling for daemons that fork() very helpful

  • 0

I found the answer in Managing Signal Handling for daemons that fork() very helpful for what I’m doing. I’m unsure about how to solve

“You will therefore need to install any signal handling in the execed process when it starts up”

I don’t have control over the process that start up. Is there any way for me to force some signal handles on the execed from the parent of the fork?

Edit:{
I’m writing a Perl module that monitors long-running processes. Instead of

system(<long-running cmd>);

you’d use

my_system(<ID>, <long-running cmd>);

I create a lock file for the <ID> and don’t let another my_system(<ID>...) call through if there is one currently running with a matching ID.

The parent fork/execs <long-running cmd> and is in change of cleaning up the lock file when it terminates. I’d like to have the child self-sufficient so the parent can exit (or so the child can take care of itself if the parent gets a kill -9).
}

  • 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-20T23:04:26+00:00Added an answer on May 20, 2026 at 11:04 pm

    On Unix systems, you can make an exec’d process ignore signals (unless the process chooses to override what you say), but you can’t force it to set a handler for it. The most you can do is leave the relevant signal being handled by the default handler.

    If you think about it, you’ll realize why. To install a signal handler, you have to provide a function pointer – but the process that does the exec() can’t specify one of its functions because they won’t exist as part of the exec’d process, and it can’t specify one of the exec’d processes functions because they don’t exist as part of the exec’ing process. Similarly, you can’t register atexit() handlers in the exec’ing process that will be honoured by the exec’d process.

    As to your programming problem, there’s a good reason that the lock file normally contains the process ID (pid) of the process that holds the lock; it allows you to check whether that process is still around, even if it isn’t your child. You can read the pid from the lock file, and then use kill(pid, 0) which will tell you if the process exists and you can signal it without actually sending any signal.

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

Sidebar

Related Questions

Searched a lot about this problem but never found a answer, that solved it.
I have found the technique in the answer below very useful for transparently managing
I found some answer that quite solve my questions, but seems that I'm missing
I found this answer and it sounds like almost exactly what I'm doing. I
I've been search and I can't found an answer that works, I need to
I've looked through the similar questions and not yet found an answer. I will
EDIT: Answer found! Thank you very much people, a lot of answers worked, I
I think I have a very popular problem, but not found answer for it
I found an answer that almost solves my problem: https://stackoverflow.com/a/5717191/1065546 This answer demonstrates how
I have a situation that I have not found an answer to when looking

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.