最佳答案
使用O_RDONLY而不是O_RDWR作为访问模式.从open(2)错误列表:
EISDIR
pathname refers to a directory and the access requested involved writing (that is,O_WRONLY
orO_RDWR
is set).