Skip to content
Tcl Source Code History Of Ticket 2406596fff
Login

History Of Ticket 2406596fff

Artifacts Associated With Ticket 2406596fff

  1. Ticket change [9cd2f84cd9] (rid 96210) by ralfixx on 2008-12-08 14:16:46:

    1. assignee initialized to: "vincentdarley"
    2. cmimetype initialized to: "text/plain"
    3. 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 ?
      
    4. foundin initialized to: "obsolete: 8.5.5"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "ralfixx"
    10. subsystem initialized to: "37. File System"
    11. title initialized to: "file delete reports an error on non-existent file"
    12. type initialized to: "Bug"
  2. Ticket change [12929f2cae] (rid 124057) by dkf on 2008-12-08 21:22:35:

    1. icomment:
      Macs *are* Unix in this area.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  3. Ticket change [13bf146148] (rid 124273) by ferrieux on 2008-12-08 21:42:29:

    1. 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.
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  4. Ticket change [83e45c63fb] (rid 259749) by serhiy.storchaka on 2026-10-21 10:03:39:

    1. 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.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  5. Ticket change [7c07226ca1] (rid 260037) by serhiy.storchaka on 2026-10-22 17:19:31:

    1. closedate changed to: "2461334.919206956"
    2. closer changed to: "serhiy.storchaka"
    3. login: "serhiy.storchaka"