Like Tree1Likes
  • 1 Post By Barney McGrew

Implement Signal() using sigaction() in ubuntu

This is a discussion on Implement Signal() using sigaction() in ubuntu within the C Programming forums, part of the General Programming Boards category; Hi... Im programming client/server app that client provide the file name then the server send it to client then the ...

  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
    2,521
    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.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  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?
    stahta01 likes this.

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-17-2010, 11:50 PM
  4. Replies: 3
    Last Post: 07-07-2009, 10:05 AM
  5. Replies: 9
    Last Post: 11-12-2007, 02:29 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21