LoginSignup
1
0

More than 3 years have passed since last update.

書いてある通りだと思ったか?そいつは間違いだ。(追記

Last updated at Posted at 2020-06-10

最近いろいろな都合でLinuxのAPIを調べる機会が多いのだが、

open()
read()

この2つに(というかread()に)致命的な間違いがある。

open()は確かに正しい。O_NONBLOCKさえ指定しなければブロックする。
だがread()はブロックしない。fdのオープンモードには関係ない。
一度read()が成功したらノンブロックで読み続ける(FIFOで実験しよう)。

read()がブロッキングしてくれると思ったら大間違いだ。
自分で確かめてみてくれ。
あえてコードは出さない。

2020/07/10追記
上記は半分間違いである。
read()でのブロッキングは可能だ。
些細な問題を除けばだが。

1
0
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0