tdm: the return value from read() should be checked