Artifacts Associated With Ticket 2406596fffffffffffffffffffffffffffffffff
Ticket change [9cd2f84cd9] (rid 96210) by ralfixx on 2008-12-08 14:16:46:
- assignee initialized to: "vincentdarley"
- cmimetype initialized to: "text/plain"
- comment initialized to:
[file delete] is documented as: Trying to delete a non-existent file is not considered an error. However, the following code reports an error when run in two simultaneous processes on Linux: #!/bin/sh -- set testfile /tmp/testfile while {1} { # create the testfile, ignore any errors catch {close [open $testfile w]} # call file delete: should not err out file delete $testfile # second call: with a single process this is no problem file delete $testfile } # End of file tclsh8.5 t.tcl => runs ok tclsh8.5 t.tcl & tclsh8.5 t.tcl => immediate error from one of the processes error deleting "/tmp/testfile": no such file or directory while executing "file delete $testfile" ("while" body line 3) invoked from within "while {1} { catch {close [open $testfile w]} file delete $testfile file delete $testfile }" (file "t.tcl" line 3) According to the documentation this error should never occur. Citing a message on comp.lang.tcl: From: Ralf Fassel <[email protected]> Newsgroups: comp.lang.tcl Subject: Re: catch and trap Date: Thu, 23 Oct 2008 22:08:48 +0200 Message-ID: <[email protected]> * "Donal K. Fellows" <[email protected]> | In order to know which syscall to use, Tcl has to lstat() it first | (lstat because we want to just remove the link if it is a symlink to | a directory); if we get ENOENT from the lstat(), we don't bother | doing anything else as the file is (probably) gone; --<snip-snip>-- But if the file is there at lstat-time, and it is a file, then in tcl-8.5.2 the result of result = Tcl_FSDeleteFile(objv[i]); is returned, which boils down to calling unlink(2) on Unix, which returns an ENOENT error for non-existing files, and *this* is then translated into TCL_ERROR (unix/tclUnixFCmd.c, TclpDeleteFile()). Proposed patch for Unix: *** tcl8.5.5/unix/tclUnixFCmd.c~Thu Dec 13 16:28:42 2007 --- tcl8.5.5/unix/tclUnixFCmd.cMon Dec 8 15:11:58 2008 *************** *** 633,639 **** TclpDeleteFile( CONST char *path)/* Pathname of file to be removed (native). */ { ! if (unlink(path) != 0) {/* INTL: Native. */ return TCL_ERROR; } return TCL_OK; --- 633,639 ---- TclpDeleteFile( CONST char *path)/* Pathname of file to be removed (native). */ { ! if (unlink(path) != 0 && errno != ENOENT) {/* INTL: Native. */ return TCL_ERROR; } return TCL_OK; Diff finished. Mon Dec 8 15:12:04 2008 patches for windows & mac ? - foundin initialized to: "obsolete: 8.5.5"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "ralfixx"
- subsystem initialized to: "37. File System"
- title initialized to: "file delete reports an error on non-existent file"
- type initialized to: "Bug"
Ticket change [12929f2cae] (rid 124057) by dkf on 2008-12-08 21:22:35:
- icomment:
Macs *are* Unix in this area.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [13bf146148] (rid 124273) by ferrieux on 2008-12-08 21:42:29:
- icomment:
First, please use 'diff -u' format ;-) Second, the proposed patch hides the truth one level too low. Indeed, it prevents any caller of TclpDeleteFile from learning about the absence of the file. I think this hiding should just happen in TclFileDeleteCmd (the caller) rather than in TclpDeleteFile (the callee). This way you won't even need a per-platform patch since it is in the generic layer.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [83e45c63fb] (rid 259749) by serhiy.storchaka on 2026-10-21 10:03:39:
- icomment:
Fixed in 8.6.9 by [5acb57c7ae] (ticket [27b6822849]): <tt>file delete</tt> now ignores ENOENT when the file vanishes between lstat() and unlink(), in the generic layer as suggested here. The two-process script fails with 8.6.8 and passes with 8.6.9 and later.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- icomment:
Ticket change [7c07226ca1] (rid 260037) by serhiy.storchaka on 2026-10-22 17:19:31:
- closedate changed to: "2461334.919206956"
- closer changed to: "serhiy.storchaka"
- login: "serhiy.storchaka"