what the kill() system call should do??

Conor P. Cahill cpcahil at virtech.uucp
Thu Sep 27 21:18:49 AEST 1990


In article <25784.2700d355 at kuhub.cc.ukans.edu> jian at kuhub.cc.ukans.edu writes:
>
>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.
>
>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);
>  }

I assume the getpid() is a typo and you really had getppid() in the code.

Most likely the child process is executing the kill() before the parent
process has a chance to execute the signal().    Try running the signal before
the fork (and if necessary, reset it in the child).

-- 
Conor P. Cahill            (703)430-9247        Virtual Technologies, Inc.,
uunet!virtech!cpcahil                           46030 Manekin Plaza, Suite 160
                                                Sterling, VA 22170 



More information about the Comp.unix.questions mailing list