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

The Archive Base Latest Questions

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

I dont understand why my code does not work. This is my code. I

  • 0

I dont understand why my code does not work.

This is my code. I don’t know why I’m get an error segment. Could somebody explain the reason to me?

#include <iostream> #include <string> #include <sys/types.h> #include <unistd.h>  int id_process;  void manager_signal () {     kill (id_process, SIGKILL);     kill (getppid(),SIGKILL); }  int main () {     id_process = fork ();     if (id_process==-1) {         perror('ERROR to create the fork');     } else {         if ( id_process != 0 ) {             printf('Father´s ID is %d \n', getpid());                alarm(5);             (void) signal (SIGALRM, manager_signal);             sleep (20);             printf ('Running to where the father can be\n');             alarm (0);                   } else {             printf ('CHildren´s ID is %d \n', getpid ());             for (;;) {                 printf ( 'Children RUN FOREVER ^^');                 sleep (2);             }         }     }     return 0; } 
  • 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. 2026-05-11T14:17:48+00:00Added an answer on May 11, 2026 at 2:17 pm

    Your question is a little difficult to understand since you don’t really explain what the error is, but I do have one question which I’m sure will be pertinent.

    Why is the ‘father’ process killing its child and its parent? Shouldn’t it kill its child and itself (id_process and getpid() rather than getppid() which is the parent PID)?

    That appears to be the problem. When I run that under Cygwin, it kills off my shell (darned annoying). If I change it to kill (getpid(),SIGKILL);, it terminates okay after five seconds with the following output:

    $ vi qq.cpp ; g++ -o qq qq.cpp ; ./qq.exe Fathers ID is 6016 Childrens ID is 4512 Children RUN FOREVER ^^ Children RUN FOREVER ^^ Children RUN FOREVER ^^ Children RUN FOREVER ^^ Children RUN FOREVER ^^ Killed 

    This is with the program modified as follows:

    #include <iostream> #include <string> #include <sys/types.h> #include <unistd.h>  int id_process;  void manager_signal (int x) {     kill (id_process, SIGKILL);     kill (getpid(),SIGKILL); }  int main () {     id_process = fork ();     if (id_process==-1) {         perror('ERROR to create the fork');     } else {         if ( id_process != 0 ) {             printf('Fathers ID is %d\n', getpid());             alarm(5);             (void) signal (SIGALRM, manager_signal);             sleep (20);             printf ('Running to where the father can be\n');             alarm (0);         } else {             printf ('Childrens ID is %d\n', getpid ());             for (;;) {                 printf ( 'Children RUN FOREVER ^^\n');                 sleep (1);             }         }     }     return 0; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 117k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This should work: str.replace(/\[url=([^\s"<>\]]+)\]/gi, '<a href="$1">$1</a>'); That should take the… May 11, 2026 at 10:50 pm
  • Editorial Team
    Editorial Team added an answer You could also just put in an absolute path from… May 11, 2026 at 10:50 pm
  • Editorial Team
    Editorial Team added an answer When catching exceptions, be as specific as possible if you… May 11, 2026 at 10:50 pm

Related Questions

I'm trying to load fragments of XHTML markup using jQuery's $.fn.load function, but it
Making my first steps with NHibernate, I'm trying to have it creating my Tables
I'm using a library - HtmlUnit - and I just updated from version 2.4
Here is my sample code. It is meant to be an iterative procedure for

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.