Unis signal handling in parent child scenario.

gnutuxy_at_yahoo.co.in
Date: 09/30/04


Date: 29 Sep 2004 22:47:15 -0700

Hi,

I am newbie in the Unix system programming and in learning phase.
I usually read the libc manual and then try to implement small
programs to test/check the learnt thing.

I read the libc manual for signals and tried the program to check
whether child
inherits the signal handler intalled by parent befor fork.

I am totally confused about it because the code won't work as per the
the manual. Manual says child inherits signal action and signal mask.

My situation is as follows:
Question : Why I won't get message "Received the signal: #" on the
terminal, when I signaled child process with SIGINT?

==================glibc manual extract==============
 * The set of pending signals (*note Delivery of Signal::) for the
   child process is cleared. (The child process inherits its mask of
   blocked signals and signal actions from the parent process.)
====================================================

My try : I just want to check that the signal handler installed in
Parent is
         inherited by child ( this is what I interpreted from the
glibc manual,
         the extract of the manual is highlighted above. )

Here is my code.
=================my code============================
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>

void mysig_handler( int signum )
{
        printf("Received the signal: %d", signum );
}

int main( int argc, char *argv[] )
{

        pid_t chld;

        signal( SIGINT, mysig_handler );

        if( ( chld = fork() ) < 0 )
        {
                //error
                printf("Fork Error!\n");
        }
        else if( chld == 0 )
        {
                //child
                while(1)
                {
                }
        }
        else
        {
                //parent
                while(1)
                {
                }
        }
        return(0);
}
====================================================
my softwares are
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
Kernel 2.2.14-12smp

Regards,
Vinay G.



Relevant Pages

  • Re: aio_connect ?
    ... using the kind of radically different programming style that the aio_* ... various kinds of I/O completion events) really _should_ be handled. ... different ways of doing _polling_ for a set of events. ... Any one of them could be hacked to make it generate signals instead, ...
    (freebsd-net)
  • Re: Verification errors using Xilinx Spartan 3E board
    ... I get some of the signals to not even be "connected" on the ... Try setting the FPGA Mode jumpers to JTAG. ... reported problems to me doing JTAG configurations on these boards when the ... This kind of errors however should yield to Programming error, ...
    (comp.arch.fpga)
  • Re: Virtex II Pro XC2VP100
    ... I have checked TCK and TMS .TDI levels .It is okay.But TDO is logic ... > What cable are you using for programming? ... >chain and the signals were not passing at 5MHz. ... >>The prog Pin is pulled up to 3.3V through 4.7k.The Init pin is pulled ...
    (comp.arch.fpga)
  • Re: are relational databases not needed when you use lisp? paul graham did not
    ... Perhaps outlandish was a wrong word, but it certainly seemed like an unusual take on object instantiation. ... error-based programming to handle normal programming situations, ... Page fault-like handling is indeed less surprising. ... However, my main objection was that signals are so brittle and offer so little in the way of a protocol. ...
    (comp.lang.lisp)
  • Re: WSJ article on software liability
    ... There is no need for multithreading in COSA in the traditional ... This is not unlike the way hardware sensors ... >> represent a behaving system (sensors, effectors, signals) is to use a ... >and/or otherwise facilitates creative problem solving, programming, ...
    (comp.programming)