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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:19:46+00:00 2026-05-22T14:19:46+00:00

I am trying to understand how CTRL + C terminates a child but not

  • 0

I am trying to understand how CTRL+C terminates a child but not a parent process. I see this behavior in some script shells like bash where you can start some long-running process and then terminate it by entering CTRL–C and the control returns to the shell.

Could you explain how does it work and in particular why isn’t the parent (shell) process terminated?

Does the shell have to do some special handling of CTRL+C event and if yes what exactly does it do?

  • 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-22T14:19:47+00:00Added an answer on May 22, 2026 at 2:19 pm

    Signals by default are handled by the kernel. Old Unix systems had 15 signals; now they have more. You can check </usr/include/signal.h> (or kill -l). CTRL+C is the signal with name SIGINT.

    The default action for handling each signal is defined in the kernel too, and usually it terminates the process that received the signal.

    All signals (but SIGKILL) can be handled by program.

    And this is what the shell does:

    • When the shell running in interactive mode, it has a special signal handling for this mode.
    • When you run a program, for example find, the shell:
      • forks itself
      • and for the child set the default signal handling
      • replace the child with the given command (e.g. with find)
      • when you press CTRL+C, parent shell handle this signal but the child will receive it – with the default action – terminate. (the child can implement signal handling too)

    You can trap signals in your shell script too…

    And you can set signal handling for your interactive shell too, try enter this at the top of you ~/.profile. (Ensure than you’re a already logged in and test it with another terminal – you can lock out yourself)

    trap 'echo "Dont do this"' 2
    

    Now, every time you press CTRL+C in your shell, it will print a message. Don’t forget to remove the line!

    If interested, you can check the plain old /bin/sh signal handling in the source code here.

    At the above there were some misinformations in the comments (now deleted), so if someone interested here is a very nice link – how the signal handling works.

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

Sidebar

Related Questions

Trying to understand this binding process of the WPF. See the code at the
Trying to understand this MSDN sample but I'm confused about these lines: IAsyncResult result
Trying to understand the options for will_paginate's paginate method: :page — REQUIRED, but defaults
Trying to understand Ruby a bit better, I ran into this code surfing the
After trying to understand why client code is not rendered in a page (injected
I've been trying to understand Process.MainWindowHandle . According to MSDN; The main window is
Trying to understand why this doesn't work. I keep getting the following errors: left
Im trying to understand how boolean logic works when I use NOT. To give
While trying to understand how a web server worked, I came accross this: //myfile.js
im trying to understand the process of creating tables in ruby-on-rails 3. i have

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.