define fd == 0 as initial value and fd == -1 as error?