what the kill() system call should do??

jian at kuhub.cc.ukans.edu jian at kuhub.cc.ukans.edu
Thu Sep 27 07:12:04 AEST 1990


I tried to send a signal (SIGUSR1) from a child process to its parent process
by using kill() system call in C. The result was funny. Whenever the parent
process received the signal, it died immediately. I don't know what goes wrong
in my program. Any help appreciated.

Jian Q. Li
jian at kuhub.cc.ukans.edu

----------------------------------------------------------------------------
Following is my sample program:

void parent_process()
{
  int ppid;
  ....

  switch( pid = fork()) {
    case -1:
      perror("for()");
      exit(1);
    case 0:
      ppid = getpid();
      child_process(ppid);
    
     default:   
       signal(SIGUSR1, catch_usr1);
  }

  .....
}

void catch_usr1()
{
  printf("Catch the SIGUSR1 signal\n");
  usr_break = 1;
}

void child_process(parent_id)
  int parent_id;
{
  ....

  kill(parent_id, SIGUSR1);

  ....
}



More information about the Comp.unix.questions mailing list