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).

Mat
  • 195,986
  • 40
  • 382
  • 396
Don't You Worry Child
  • 5,896
  • 2
  • 24
  • 50

2 Answers2

9

POLLRDHUP is a non-standard extension (it is missing from POSIX). To prevent polluting the namespace, non-standard extensions are not visible unless you explicitly request them by defining _GNU_SOURCE.

More details on _GNU_SOURCE can be found in previous StackOverflow answers such as this one.

Community
  • 1
  • 1
user4815162342
  • 124,516
  • 15
  • 228
  • 298
2

_GNU_SOURCE is a feature test macros which is useful for creating portable applications, by preventing nonstandard definitions from being exposed.

Dayal rai
  • 6,308
  • 21
  • 29