Ex 5.3 form The Linux Programming Interface by Michel Kerrisk