]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
CODING_STYLE: document why O_NONBLOCK makes sense when opening regular files, too
authorLennart Poettering <lennart@poettering.net>
Fri, 9 Mar 2018 20:35:48 +0000 (21:35 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 28 Mar 2018 20:03:34 +0000 (22:03 +0200)
doc/CODING_STYLE

index ae818126cb92218f0508da598a2410a36ec8c9dd..66771ef523180c89a7df78379e7093cafef1521b 100644 (file)
   string, always apply the C-style unescaping fist, followed by the specifier
   expansion. When doing the reverse, make sure to escape '%' in specifier-style
   first (i.e. '%' → '%%'), and then do C-style escaping where necessary.
+
+- It's a good idea to use O_NONBLOCK when opening 'foreign' regular files, i.e
+  file system objects that are supposed to be regular files whose paths where
+  specified by the user and hence might actually refer to other types of file
+  system objects. This is a good idea so that we don't end up blocking on
+  'strange' file nodes, for example if the user pointed us to a FIFO or device
+  node which may block when opening. Moreover even for actual regular files
+  O_NONBLOCK has a benefit: it bypasses any mandatory lock that might be in
+  effect on the regular file. If in doubt consider turning off O_NONBLOCK again
+  after opening.