'glibc'에 해당되는 글 1건

  1. 2010.11.19 [Linux][C/C++] 'select' function - glibc bug??

[Linux][C/C++] 'select' function - glibc bug??

Language/C&C++ 2010.11.19 18:04

Following test is done with "Ubuntu EGLIBC 2.12.1-0ubuntu9"

Based on my simple test, 'select' function is poor to validate file descriptor.
In my test, select doesn't return error (-1) even for file descriptor 99999. Some times process is crashed - segment fault.
So, file descriptor should be validated before calling 'select'.
(I think I need to look into more about this. These are based on just test. So I'm not 100% sure about this.)

There is lot's of way. Here is well-known way.

is_valid_fd(int fd) { fcntl(fd, F_GETFL) != -1 || errno != EBADF; }

Summay. Be careful using 'select'!

tags :
Trackback 0 : Comment 0

티스토리 툴바