working code for Advanced Programming in the UNIX Environment 2ed preferably on Ubuntu/gcc4
rotkas has a github repo that contains the code with modifications to make it compile on modern systems. It worked for me on OSX 10.7 and Ubuntu 10.04. Haven't needed it recently, though.
I downloaded the source and then, as per the README file, edited Make.defines.linux and changed WKDIR to point to where I had unpacked the source code. Then I ran make and just about everything compiled with only a few warnings.
threadctl didn't compile, though, and I had to change #include <limits.h>
to #include <linux/limits.h>
in getenv1.c and getenv3.c before it would compile (not sure if this is the best fix, but it works.)
Thank you Jacinda for the link it worked for me, but I had to do something else too
I used the source code from github/roktas and used the following command in order to run the programs
gcc -o myls myls.c -I SCADDRESS/include/ -L SCADDRESS/lib/ -lapue
if anyone has the same problem can go to this link.