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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:12:56+00:00 2026-06-02T11:12:56+00:00

My signal handler looks like: volatile sig_atomic_t loop = 1; void handle() { loop

  • 0

My signal handler looks like:

volatile sig_atomic_t loop     = 1;

void handle()
{
    loop = 0;
}

And, I have a daemon which is like:

void _start_()
{
...
sa.sa_handler = handle;
sigaction(SIGINT, &sa, NULL);
while(loop)
{
   //add a line to a file
}
...
}

I want to stop the daemon, from another function like:

void _stop_()
{
    raise(SIGINT);
}

My idea is, somehow if the value of loop is 0, then the while would be evaluated as false, and the daemon exits.
I am planning to use these two functions like:

_start_(); //daemon starts
//computation
_stop_() //daemon stops writing to the file. exits

How can I achieve this? The problem is I am not able to stop the daemon from _stop_().

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-02T11:12:58+00:00Added an answer on June 2, 2026 at 11:12 am

    Is the _stop() function called from a separate process from your daemon? If so, then it needs to know the ID of the process to signal. Normal practice is that the daemon writes its process ID to a file (a PID file) which can the be read by the process that stops the daemon.

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

Sidebar

Related Questions

I have a signal handler which does its job, but the only ugly thing
#include<stdio.h> #include<signal.h> #include<stdlib.h> void handler(int signo) { printf(First statement); system(date); exit(EXIT_SUCCESS); } int main()
I have a QMainWindow, and want to handle the clicked signal from a smaller
So I'm trying to create a signal handler using pthreads which works on both
Can I provide/pass any arguments to signal handler? /* Signal handling */ struct sigaction
Any idea why the signal handler goes to infinite loop? Here is the code.
I have a function that I want to use as an event handler: void
Why is calling a standard library function inside a signal handler discouraged?
Using C on Linux, how would I go about triggering a signal handler every
How do you handle clean up when the program receives a kill signal? For

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.