Don't use /proc if there are other ways to get the information. For example, use setprogname(argv[0]) in main() and then getprogname() if you want to "know your name".
Don't rely on undocumented (by POSIX) behavior. 1
- Don't record timestamps in the critical path of the app if it also works without (getting timestamps may be slow, depending on the accuracy of timestamps in the OS). If you have to get timestamps, determine how precise they have to be and use an API, which is documented to just deliver the needed precision.
A number of simple syscalls (for example gettimeofday, getpid) are much faster on Linux than on any other operating system due to caching and the vsyscall performance optimizations. Do not rely on them being cheap in performance-critical applications. In general, try hard to avoid syscalls if at all possible.
Do not rely on Linux-specific socket behaviour. In particular, default socket buffer sizes are different (call setsockopt() with SO_SNDBUF and SO_RCVBUF), and while Linux's send() blocks when the socket buffer is full, FreeBSD's will fail and set ENOBUFS` in errno. 1
- If you absolutely need to rely on non-standard behaviour, properly encapsulate it into a generic API, do a check for the thing in the configure stage and bail out if it's missing.
Check the FreeBSD Manual Pages to see if the function you use is a POSIX interface ("STANDARDS" section of the man page).
Do not assume that /bin/sh is bash. Ensure that a command line passed to system() will work with a POSIX compliant shell.
Here is a list of common bash'isms (wiki.ubuntu.com)
Do not #include <stdint.h> if inttypes.h is sufficient. This will assure that your software builds on older versions of FreeBSD.
Check that you include headers in the way recommended through POSIX or the man-page. Eg. sys/types.h is often forgotten, which doesn't seem to be as much of a problem for Linux as for FreeBSD.
Compile threaded apps with -pthread, not -lpthread or variations thereof. 2