Ex 5.1 form The Linux Programming Interface by Michel Kerrisk