include sys/types.h for this example code (address Magda's compile problems)