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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:17:51+00:00 2026-05-27T14:17:51+00:00

While learning signal() system call, I supposed to come across the following code, #include

  • 0

While learning signal() system call, I supposed to come across the following code,

#include <stdio.h>
#include <signal.h>
void sigproc(int);
void quitproc(int);

int main(int argc,char **argv)
{
 signal(SIGINT, sigproc); //Is it like a normal Call to signal()?
 signal(SIGQUIT, quitproc);// This too?
 printf("ctrl- c disabled use ctrl\ to quit \n");
 while(1);
 return 0;
}

void sigproc(int signo)
{
printf("you have pressed ctrl - c \n");
}

void quitproc(int signo)
{
  printf("U cant quit\n");
//  exit(0);
}

I am calling the function signal() twice in main(). But its executed only when I’m pressing Ctrl-C and Ctrl-\ keys. I thought its also like normal function call. What is actually happening in the signal handler functions?

  • 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-27T14:17:51+00:00Added an answer on May 27, 2026 at 2:17 pm

    The signal function establishes a signal handler. What it means: “When my process receives this signal, run this function instead of doing whatever the default was“.

    So, in your example the calls to signal don’t call the function. To actually see the signals in action, do this:

    • Start your process in one terminal
    • From another terminal:

      kill -INT `pidof proc`
      

    As a side note, printf and friends aren’t async-signal-safe. It might come as a shocker, but it’s unsafe to use them in signal handlers.


    As a side side note, even if you tagged your question Unix it’s important to know that signals (and the signal function) are standard, integral parts of C. Signal handling and the signal function are described in C99 in §7.14.1.

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

Sidebar

Related Questions

I came across the word 'The Turkey Test' while learning about code testing. I
While learning to use LINQ in VB.NET, I came across the following: Dim x
While learning C I regularly come across resources which recommend that some functions (e.g.
I am confuse where can i make my code to n-tier: While learning n-tier
While learning on anonymous methods, i've found the following example on the internet: namespace
I am trying to program (while learning JQuery) the following: I have a form
I came across several interfaces while learning JDBC - Connection, Statement, ResultSet etc... Does
While learning Prolog, I'm trying to solve the following problem, using accumulators: Write a
While learning Sitecore I have found that the majority of Sitecore sample code on
While learning the concept of copying members, the book gives the following statement. In

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.