From: Lennart Poettering Date: Fri, 9 Mar 2018 20:35:48 +0000 (+0100) Subject: CODING_STYLE: document why O_NONBLOCK makes sense when opening regular files, too X-Git-Tag: v239~457^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fda8a890460c7c627ce65897ed64929f8a8ef0cb;p=platform%2Fupstream%2Fsystemd.git CODING_STYLE: document why O_NONBLOCK makes sense when opening regular files, too --- diff --git a/doc/CODING_STYLE b/doc/CODING_STYLE index ae81812..66771ef 100644 --- a/doc/CODING_STYLE +++ b/doc/CODING_STYLE @@ -440,3 +440,13 @@ 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.