Thread: Implement Signal() using sigaction() in ubuntu

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    20

    Question Implement Signal() using sigaction() in ubuntu

    Hi...
    Im programming client/server app that client provide the file name then the server send it to client then the client will save it ..

    so i want to make signal handler to handle zombie problem between parent and child so this code for signal :

    Code:
    Sigfunc *
    signal(int signo, Sigfunc *func)
    {
        struct sigaction    act, oact;
    
        act.sa_handler = func;
        sigemptyset(&act.sa_mask);
        act.sa_flags = 0;
        if (signo == SIGALRM) {
    #ifdef    SA_INTERRUPT
            act.sa_flags |= SA_INTERRUPT;    /* SunOS 4.x */
    #endif
        } else {
    #ifdef    SA_RESTART
            act.sa_flags |= SA_RESTART;        /* SVR4, 44BSD */
    #endif
        }
        if (sigaction(signo, &act, &oact) < 0)
            return(SIG_ERR);
        return(oact.sa_handler);
    }
    /* end signal */
    The filename is : myHeader.h
    and the error when compile the file is :

    gcc -Wall -I/home/zmhnk/Desktop/ -o "myHeader" "myHeader.h" (in directory: /home/zmhnk/Desktop)
    myHeader.h:281:1: error: unknown type name ‘Sigfunc’
    myHeader.h:282:19: error: unknown type name ‘Sigfunc’
    Compilation failed.


    so how to solve this problem

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    I see no includes in what you posted; I suggest adding them to the post if you have them.
    If you do NOT have them, then you need include the correct header (that defines Sigfunc) to get the code to compile.

    Edit1: You do know that headers are not normally compiled.
    Edit2: And, functions bodies are not normally in C header files.
    Edit3: Sigfunc seems to be a MS Windows function; Google has not given me much hope it is a missing Linux header issue.

    Tim S.
    Last edited by stahta01; 03-22-2013 at 06:43 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Stoned Witch Barney McGrew's Avatar
    Join Date
    Oct 2012
    Location
    astaylea
    Posts
    420
    This function is already provided by your standard C library. Why on earth are you remaking it?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. signal to sigaction conversion
    By gemera in forum C Programming
    Replies: 12
    Last Post: 09-25-2012, 10:01 PM
  2. struct sigaction
    By ssharish2005 in forum C Programming
    Replies: 1
    Last Post: 07-17-2011, 08:41 AM
  3. signal vs sigaction
    By bhrugu in forum C Programming
    Replies: 1
    Last Post: 01-18-2010, 12:50 AM
  4. Replies: 3
    Last Post: 07-07-2009, 10:05 AM
  5. Replies: 9
    Last Post: 11-12-2007, 03:29 PM

Tags for this Thread