A NOTE has been added to this issue. ====================================================================== http://austingroupbugs.net/view.php?id=1016 ====================================================================== Reported By: izabera Assigned To: ====================================================================== Project: 1003.1(2013)/Issue7+TC1 Issue ID: 1016 Category: Shell and Utilities Type: Enhancement Request Severity: Editorial Priority: normal Status: New Name: Isabella Organization: --- User Reference: --- Section: 2.7.2 Page Number: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_02
Line Number: last paragraph Interp Status: --- Final Accepted Text: ====================================================================== Date Submitted: 2015-12-28 13:52 UTC Last Modified: 2016-11-11 21:26 UTC ====================================================================== Summary: race condition with set -C ====================================================================== ---------------------------------------------------------------------- (0003486) stephane (reporter) - 2016-11-11 21:26 http://austingroupbugs.net/view.php?id=1016#c3486 ---------------------------------------------------------------------- The part about adding O_NOCLOBBER is unreasonable in my opinion, that would be adding a feature to the kernel (and probably difficult to implement without for instance modifying network file system protocols) just to work around a short-coming in a misfeature of one application (sh). I can't think of any other reason why one may want to use such a O_NOCLOBBER (O_EXCL only if the file is regular) flag. "set -C" is the solution the sh developers came up with to allow users to redirect without clobbering files, and then realised it wasn't convenient when redirecting to /dev/null or named pipes. The problem here is not as much that a O_NOCLOBBER is missing to make that reliable, but that "set -C" feature in the first place which is using a global setting where users only need to affect the behaviour of *some* redirections. Most sh features that make use of global settings (IFS, CDPATH, noglob, errexit, nounset, even LC_*) are a problem and source of headaches to write reusable code, especially considering that POSIX sh has no local (let alone private) scope for those. Here, it could make a lot more sense to have a dedicated redirection operator that uses O_EXEC than having a O_CLOBBER flag so that only some redirections only are affected by a global set -C setting. Something like: cmd (excl)> newfile 2> /dev/null To allow more flags (O_NOFOLLOW, O_CLOEXEC and the ability to turn on/off some of the flags for <>, >>, > redirections are also badly missing). Like above, if we wanted to be pedantic, we'd want to write: cmd (excl)> newfile 2(nocreate)> /dev/null to avoid creating a /dev/null regular file if it wasn't there in the first place. There are far more important race conditions to address IMO (even at kernel level like a rename() that doesn't clobber the destination) than this one. Like the missing mv/cp/ln -T/-n, the find -execdir, mktemp, cd with nofollow... Issue History Date Modified Username Field Change ====================================================================== 2015-12-28 13:52 izabera New Issue 2015-12-28 13:52 izabera Name => Isabella 2015-12-28 13:52 izabera Organization => --- 2015-12-28 13:52 izabera User Reference => --- 2015-12-28 13:52 izabera Section => 2.7.2 2015-12-28 13:52 izabera Page Number => http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_02 2015-12-28 13:52 izabera Line Number => last paragraph 2015-12-31 05:58 shware_systems Note Added: 0002990 2015-12-31 12:52 jilles Note Added: 0002991 2015-12-31 14:21 shware_systems Note Added: 0002992 2015-12-31 17:05 nick Interp Status => --- 2015-12-31 17:05 nick Note Added: 0002993 2015-12-31 17:05 nick Description Updated 2016-10-20 16:40 geoffclare Note Added: 0003446 2016-10-31 16:23 geoffclare Note Added: 0003481 2016-10-31 16:28 geoffclare Note Edited: 0003481 2016-10-31 16:33 geoffclare Note Edited: 0003481 2016-11-10 17:33 rhansen Note Added: 0003485 2016-11-10 17:36 rhansen Note Edited: 0003485 2016-11-10 17:37 rhansen Note Edited: 0003485 2016-11-11 15:24 rhansen Note Edited: 0003485 2016-11-11 15:25 rhansen Note Edited: 0003485 2016-11-11 15:27 rhansen Note Edited: 0003485 2016-11-11 15:29 rhansen Note Edited: 0003485 2016-11-11 15:29 rhansen Note Edited: 0003485 2016-11-11 15:30 rhansen Note Edited: 0003485 2016-11-11 21:26 stephane Note Added: 0003486 ======================================================================