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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:01:31+00:00 2026-06-03T18:01:31+00:00

I have one simple question about signals in Linux systems. As I understand every

  • 0

I have one simple question about signals in Linux systems. As I understand every process has it’s PID and PGID. When I create a process it gets it’s unique PID, now if I would fork a new process with fork() function I would get child process with different PID but the same PGID.

Now, the code

#include<stdio.h>
#include<unistd.h>
int main()
{
  int i=3;
  int j;
  for(j=0;j<i;++j)
  {
      if (fork() == 0)
      {
          while(1)
          {

          }
      }
  }
  printf("created\n");
  while(1)
  {

  }
  return 0;
}

when I compile this program and run it with the command

./foo

and wait a sec so he creates his children and I do CTRL-C and then ps aux I can see that the parent and the children are gone, but if I do

./foo

wait for forking to complete and in other terminal do

kill -INT <pid_of_foo>

and ps aux I can see that the parent is gone but children are still alive and eating my CPU.

I am not sure, but it seems that CTRL-C sends the signal to every process that is in some process group and the KILL -SIGNAL pid command sends the signal to the process with PID=pid not PGID=pid.

Am I on the right track? If yes, why the key combination kills processes with PGID and not PID?

  • 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-03T18:01:36+00:00Added an answer on June 3, 2026 at 6:01 pm

    Signal delivery, process groups, and sessions

    Yes, you are on the right track.

    Modern Unix variants since the BSD releases implement sessions and process groups.

    You can look at sessions as groups of process groups. The idea was that everything resulting from a single login on a tty or pseudo-tty line is part of a session, and things relating to a single shell pipeline or other logical grouping of processes would be organized into a single process group.

    This makes moving “jobs” between the foreground and background and delivering signals more convenient. The shell users mostly doesn’t need to worry about individual processes but can control-C a group of related commands in an intuitive manner.

    Signals generated by the keyboard are sent to the foreground process group in a session. The CLI kill command you are using delivers signals to individual processes. If you want to try to duplicate the ^C delivery mechanism you can use kill 0; that will send the signal to every member of the same process group, and if executed from a script it may do what you want.


    Note: I edited your question to change GPID to PGID.

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

Sidebar

Related Questions

A simple question about Stored Procedures. I have one stored procedure collecting a whole
I have one simple question about throwing exeptions in re.match function Is there a
I just have one simple question about XSS attack. I know that you can
One simple question.. Let's suppose in Matlab we have a variable: numEntries = 8
this time i have a simple question: I have one table, related with himself
Hopefully a simple question although one I have found impossible to answer myself using
I have a simple question related to one-line programming. First an example: function test(a)
I have a fairly simple question: how to take one row of cv::Mat and
The question is a very simple one, can you have more than one index
Simple question, I think. I have org.springframework.scheduling.quartz.CronTriggerBean triggering one job once a day. Because

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.