小编fir*_*irk的帖子

fgets(), signals (EINTR) and input data integrity

fgets() was intended for reading some string until EOF or \n occurred. It is very handy for reading text config files, for example, but there are some problems.

First, it may return EINTR in case of signal delivery, so it should be wrapped with loop checking for that.

Second problem is much worse: at least in glibc, it will return EINTR and loss all already read data in case it delivered in middle. This is very unlikely to happen, but …

c posix signals stdio libc

5
推荐指数
2
解决办法
135
查看次数

标签 统计

c ×1

libc ×1

posix ×1

signals ×1

stdio ×1