- Don't use /proc if there are other ways to get the information, e.g. setprogname(argv) in main() and then getprogname() if you want to "know your name".
- Don't rely on undocumented (by POSIX) behavior.
- 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.
- 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 man pages at http://www.freebsd.org/cgi/man.cgi 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.
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 That Other OS as for FreeBSD.
- Compile threaded apps with "-pthread", not "-lpthread" or variations thereof.
A list of common bashisms is available at https://wiki.ubuntu.com/DashAsBinSh