2

I am trying to find the select() source code (Linux, i386 arch) in the glibc source code, but I cannot find anything that is related to the said architecture.

Could anybody point me to the select() source code?

2 Answers 2

6

mh's answer is pretty good, but I will try to be more specific:

select is Linux system call, not libc function. It's source code could be found here.

libc has only wrapper for calling (executing) linux system call. Wrapper for select syscall is created on the fly at build time, because select is in syscalls.list file.

Sign up to request clarification or add additional context in comments.

Comments

4

select() is not a function of the libc, but a kernel function, so you need to take a look into the kernel source.

You can tell this by looking into the man page: If it is in section 2, it's a kernel function, if it's in section 3, it's a function of the standard C library, in your case the glibc.

Edit: Like some other people remarked correctly (thank you!), a function described in section 2 is officially called a system call and it is actually a call to a library that wraps the operating system's actual call interface.

4 Comments

Note that this 2/3 division still mostly holds true, but sometimes the libc must provide significant parts/wrapping of "section 2" functions in order to conform to modern POSIX requirements, especially when it comes to the interaction between signals and threads. As such, sometimes you need to look at libc source too even when the function is in section 2 of the manual. But select is not one of those cases.
What is kernel function? The only way userspace can access kernel is via syscall. But to start syscall you must have some wrapping in libc. Is it right?
The point is that the glibc function is trivial - it doesn't do anything interesting (unless you're interested in the calling convention for 5-argument syscalls on your architecture). Ultimately, in glibc many system calls don't have a definition in source code at all - they're generated at build time from syscalls.list.
Thanks all for your answers, it's exactly what i was looking for

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.