2012-03-03 4 views
2
struct siginfo { 

    int si_signo; /* signal number */ 
    int si_errno; /* if nonzero, errno value from <errno.h> */ 
    int si_code; /* additional info (depends on signal) */ 
    pid_t si_pid; /* sending process ID */ 
    uid_t si_uid; /* sending process real user ID */ 
    void *si_addr; /* address that caused the fault */ 
    int si_status; /* exit value or signal number */ 
    long si_band; /* band number for SIGPOLL */ 
    /* possibly other fields also */ 

}; 

나는 이해할 수 없다 si_band. 당신이 sigaction의 리눅스 맨 페이지를 보면SIGPOLL의 밴드 번호는 무엇입니까?

답변

1

, 당신은 그것을 볼 수 있습니다 :

  • SIGPOLL/SIGIOsi_bandsi_fd 채 웁니다. si_band 이벤트는 비트 마스크이며 Revents 필드에 채워지는 것과 동일한 값을 poll(2)으로 포함합니다. si_fd 필드는 I/O 이벤트 이 발생한 파일 설명자를 나타냅니다.

그 비트 마스크 수단은 링크 된 사람이 페이지에서 찾을 수 있습니다 무엇에 대한 설명 - 기본적으로,이 신호를 트리거 이벤트의 유형 신호 처리기를 알려줍니다 (리눅스 적어도, 당신은 또한 해당 얻을 파일 설명 자.)

나는 이것이 얼마나 휴대용인지 모르겠다. si_band은 POSIX에 있지만, si_fd에는없는 것으로 보입니다. 참조 : POSIX <signal.h>, POSIX poll(2)

1

프로세스는 비동기 입출력을 구현하기 위해 SIGPOLL 신호를 요구할 수 있습니다. man page of sigactions에서 :

SIGPOLL/SIGIO si_band 및 si_fd 채 웁니다. si_band 이벤트는 비트 마스크이며 poll (2)에 의해 Revents 필드 에 채워진 것과 동일한 값을 포함합니다.

revents은 발생한 이벤트 유형을 나타내며 SIGPOLL이 전송됩니다. man page of poll는 상세를 설명

revents 필드 실제로 발생 이벤트와 커널 채워진 출력 파라미터이다. revents에 반환되는 비트 이 포함될 수 있습니다

POLLIN There is data to read. 

POLLPRI 
     There is urgent data to read (e.g., out-of-band data on TCP 
     socket; pseudoterminal master in packet mode has seen state 
     change in slave). 

POLLOUT 
     Writing now will not block. 

POLLRDHUP (since Linux 2.6.17) 
     Stream socket peer closed connection, or shut down writing half 
     of connection. The _GNU_SOURCE feature test macro must be 
     defined (before including any header files) in order to obtain 
     this definition. 

POLLERR 
     Error condition (output only). 

POLLHUP 
     Hang up (output only). 

POLLNVAL 
     Invalid request: fd not open (output only).