2013-03-22 97 views
0

進出口編程客戶機/服務器應用程序,客戶端提供文件名,則服務器將其發送給客戶端,客戶機將其保存..實現在Ubuntu的sigaction()信號()

,所以我想使信號處理程序來處理父母與子女之間的殭屍的問題,所以這個代碼信號:

enter code here 

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 ??? 
+0

缺少一些'#include'?在這裏(Fedora),你必須包含'',它是'sighandler_t',沒有'Sigfunc'的視線。 – vonbrand 2013-03-22 21:23:12

回答

1

您需要聲明Sigfunc,所以把這樣的事情在你的頭文件:

typedef void (*Sigfunc)(int sig_no); 

在你的頭文件中。

由於已經有一個名爲signal的標準函數,所以您需要爲其他函數命名。

+0

謝謝,我會嘗試,直到你結果是什麼? – zak 2013-03-22 21:28:07