6

I am using poll() function in my program, I read this link that to use POLLRDHUP flag you have to define _GNU_SOURCE before all header file inclusion. I needed this flag so that polling the socket can tell me whether the client has hung up or not, so that I can terminate the corresponding thread.

By the way I am writing a C program for an 'echo' server which can handle multiple clients concurrently, and I am using GCC 4.1.2 on OpenSuse Linux Enterprise Server 10.3 (x86_64).

4

2 回答 2

9

POLLRDHUP是一个非标准扩展(POSIX 中缺少它)。为了防止污染命名空间,非标准扩展是不可见的,除非您通过定义_GNU_SOURCE明确请求它们。

更多细节_GNU_SOURCE可以在以前的 StackOverflow 答案中找到,例如这个

于 2013-08-13T11:40:13.423 回答
2

_GNU_SOURCE是一种功能测试宏,可用于防止暴露非标准定义,从而有助于创建可移植应用程序。

于 2013-08-13T11:41:04.223 回答