On that topic, I really liked Advanced Unix Programming by Marc Rochkind. [1] It was an early Unix programming book and covered very well how to correctly use many important Unix system calls and showed how to write some non-trivial apps including a simple DBMS, using them. IIRC I read recently that he is coming out with a new edition after many years:
http://basepath.com/aup/
[1] I got to read it because it used to be shipped for free with all HP-UX servers for some time, when I was working in an HP joint venture company.