Find the source code of a library function in FreeBSD

To find the source code of a library function in FreeBSD, for example errx, first of all type

man errx
to get the manual page for the function. At the top left and right are the name of the manual page, in this case ERR(3). This means the main manual page is err, and it's section three of the manual, so the master file for the manual page is a file called err.3. Locate the manual page for the function under the /usr/src tree using find:
cd /usr/src
find . -name "err.3"
On my system, this produces output
[ben@mikan] src 572 $ find . -name "err.3"
find: ./sys/libkern/arm: Permission denied
[ben@mikan] src 573 $ 
The file we want is in /usr/src/lib/libc/gen/err.3. Change directory to that directory, and the source code for errx can be found in the file err.c.
Copyright © Ben Bullock 2009-2021. All rights reserved. For comments, questions, and corrections, please email Ben Bullock ( or use the discussion group at Google Groups. News about the site. / Privacy / Disclaimer