----- Original Message ----- 
From: "mayla123_2000" 
To: 
Sent: Wednesday, May 26, 2004 9:53 AM
Subject: [UTTARA] How do u find return value of signal(SIGPIPE,SIG_IGN)


> How do u find return value of signal(SIGPIPE,SIG_IGN)
> in a program in an application.
> 
> Regards

    This is a good question, something which never occurred to me.  Truly,
the real learning happens only when the mind is assigned some work that
involves reading, understanding, detection and/or inference.  

    And, I think, your question is, `what is the return type of signal()?'
Here is an explanation:

The prototype of signal() function is:

    #include 
    void (*signal(int sig, void (*func)(int)))(int); 

One:

    As you know, the signal() function takes two arguments: the first argument
is the signal number, whereas the second is the signal handler.  The prototype
of signal handler is:
    
    void handler ( int sig );

Two:

    The type of the handler can be declared as:

    typedef void (*handle_t)(int);

Three:

    Now, the signal() function's prototype can be rewritten as:

    void (*signal(int sig, handle_t func))(int);
    
    The section 5.12, Complicated Declarations, of K&R says:
    
        "C is sometimes castigated for the syntax of its declarations, 
         particularly ones that involve pointers to functions. ..."
    
    and, the above declaration in no excuse!  
    
Four:

    Follow the steps as described in the question 44 of the FAQ page.  In short,
the declaration of signal() function can be simplified as:

    typedef void (*handle_t)(int);
    handle_t signal ( int sig, handle_t func );


    i.e., signal() function returns the address of previously installed
signal handler.

    Source: geocities.com/vijoeyz/faq/c

               ( geocities.com/vijoeyz/faq)                   ( geocities.com/vijoeyz)