刚开始学,请高手们指教。
作串口中断程序,用到sigaction。
struct sigaction saio;
saio.sa_handler = signal_handler_IO;
saio.sa_mask = 0; //加上此句,编译时就出现错误 ???????????????
saio.sa_flags = 0;
saio.sa_restorer =NULL ;
sigaction(SIGIO,&saio,NULL);
高手们帮忙看看!!
|
sa_mask不是简单类型,是一个结构。
用sigemptyset(&saio.sa_mask)
另外,以后提问请附上错误信息。
|
看不懂英语就拿翻译软件翻译一下。
#include
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
struct sigaction {
void (*sa_handler)(int);
void (*sa_sigaction)(int, siginfo_t *, void *);
sigset_t sa_mask;
int sa_flags;
void (*sa_restorer)(void);
};
siginfo_t {
int si_signo; /* Signal number */
int si_errno; /* An errno value */
int si_code; /* Signal code */
pid_t si_pid; /* Sending process ID */
uid_t si_uid; /* Real user ID of sending process */
int si_status; /* Exit value or signal */
clock_t si_utime; /* User time consumed */
clock_t si_stime; /* System time consumed */
sigval_t si_value; /* Signal value */
int si_int; /* POSIX.1b signal */
void * si_ptr; /* POSIX.1b signal */
void * si_addr; /* Memory location which caused fault */
int si_band; /* Band event */
int si_fd; /* File descriptor */
};
[code=BatchFile]The sigaction() system call is used to change the action taken by a process
on receipt of a specific signal.
signum specifies the signal and can be any valid signal except SIGKILL and
SIGSTOP.
If act is non-null, the new action for signal signum is installed from act.
If oldact is non-null, the previous action is saved in oldact.
On some architectures a union is involved: do not assign to both sa_handler
and sa_sigaction.
The sa_restorer element is obsolete and should not be used. POSIX does not
specify a sa_restorer element.
sa_handler specifies the action to be associated with signum and may be
SIG_DFL for the default action, SIG_IGN to ignore this signal, or a pointer
to a signal handling function. This function receives the signal number as
its only argument.
......
[/code]