Skip to content
Tcl Source Code Artifact [9cd2f84cd9]
Login

Artifact [9cd2f84cd9]

Artifact 9cd2f84cd91d891947c095161ee71d334b50f50d:

Ticket change [9cd2f84cd9] - New ticket [2406596fffffffff|2406596fff] <i>file delete reports an error on non-existent file</i>. by ralfixx on 2008-12-08 14:16:46.
D 2008-12-08T14:16:46
J assignee vincentdarley
J cmimetype text/plain
J comment [file\sdelete]\sis\sdocumented\sas:\n\s\s\sTrying\sto\sdelete\sa\snon-existent\sfile\sis\snot\sconsidered\san\serror.\n\nHowever,\sthe\sfollowing\scode\sreports\san\serror\swhen\srun\sin\stwo\nsimultaneous\sprocesses\son\sLinux:\n\n\s\s\s\s#!/bin/sh\s--\n\s\s\s\sset\stestfile\s/tmp/testfile\n\s\s\s\swhile\s{1}\s{\n\s\s\s\s\s\s\s\s#\screate\sthe\stestfile,\signore\sany\serrors\ncatch\s{close\s[open\s$testfile\sw]}\n#\scall\sfile\sdelete:\sshould\snot\serr\sout\nfile\sdelete\s$testfile\n#\ssecond\scall:\swith\sa\ssingle\sprocess\sthis\sis\sno\sproblem\nfile\sdelete\s$testfile\n\s\s\s\s}\n\s\s\s\s#\sEnd\sof\sfile\n\n\s\s\s\stclsh8.5\st.tcl\n\s\s\s\s=>\sruns\sok\n\n\s\s\s\stclsh8.5\st.tcl\s&\stclsh8.5\st.tcl\n\s\s\s\s=>\simmediate\serror\sfrom\sone\sof\sthe\sprocesses\n\s\s\s\serror\sdeleting\s"/tmp/testfile":\sno\ssuch\sfile\sor\sdirectory\nwhile\sexecuting\n\s\s\s\s"file\sdelete\s$testfile"\n("while"\sbody\sline\s3)\ninvoked\sfrom\swithin\n\s\s\s\s"while\s{1}\s{\ncatch\s{close\s[open\s$testfile\sw]}\nfile\sdelete\s$testfile\nfile\sdelete\s$testfile\n\s\s\s\s}"\n(file\s"t.tcl"\sline\s3)\n\nAccording\sto\sthe\sdocumentation\sthis\serror\sshould\snever\soccur.\n\nCiting\sa\smessage\son\scomp.lang.tcl:\n\n\s\s\s\sFrom:\sRalf\sFassel\s<[email protected]>\n\s\s\s\sNewsgroups:\scomp.lang.tcl\n\s\s\s\sSubject:\sRe:\scatch\sand\strap\n\s\s\s\sDate:\sThu,\s23\sOct\s2008\s22:08:48\s+0200\n\s\s\s\sMessage-ID:\s<[email protected]>\n\n\s\s\s\s*\s"Donal\sK.\sFellows"\s<[email protected]>\n\s\s\s\s|\sIn\sorder\sto\sknow\swhich\ssyscall\sto\suse,\sTcl\shas\sto\slstat()\sit\sfirst\n\s\s\s\s|\s(lstat\sbecause\swe\swant\sto\sjust\sremove\sthe\slink\sif\sit\sis\sa\ssymlink\sto\n\s\s\s\s|\sa\sdirectory);\sif\swe\sget\sENOENT\sfrom\sthe\slstat(),\swe\sdon't\sbother\n\s\s\s\s|\sdoing\sanything\selse\sas\sthe\sfile\sis\s(probably)\sgone;\n\s\s\s\s--<snip-snip>--\n\n\s\s\s\sBut\sif\sthe\sfile\sis\sthere\sat\slstat-time,\sand\sit\sis\sa\sfile,\sthen\sin\n\s\s\s\stcl-8.5.2\sthe\sresult\sof\n\s\s\s\s\s\s\sresult\s=\sTcl_FSDeleteFile(objv[i]);\n\s\s\s\sis\sreturned,\swhich\sboils\sdown\sto\scalling\sunlink(2)\son\sUnix,\swhich\n\s\s\s\sreturns\san\sENOENT\serror\sfor\snon-existing\sfiles,\sand\s*this*\sis\sthen\n\s\s\s\stranslated\sinto\sTCL_ERROR\s(unix/tclUnixFCmd.c,\sTclpDeleteFile()).\n\n\s\s\s\n\nProposed\spatch\sfor\sUnix:\n\n***\stcl8.5.5/unix/tclUnixFCmd.c~Thu\sDec\s13\s16:28:42\s2007\n---\stcl8.5.5/unix/tclUnixFCmd.cMon\sDec\s\s8\s15:11:58\s2008\n***************\n***\s633,639\s****\n\s\sTclpDeleteFile(\n\s\s\s\s\s\sCONST\schar\s*path)/*\sPathname\sof\sfile\sto\sbe\sremoved\s(native).\s*/\n\s\s{\n!\s\s\s\s\sif\s(unlink(path)\s!=\s0)\s{/*\sINTL:\sNative.\s*/\n\s\sreturn\sTCL_ERROR;\n\s\s\s\s\s\s}\n\s\s\s\s\s\sreturn\sTCL_OK;\n---\s633,639\s----\n\s\sTclpDeleteFile(\n\s\s\s\s\s\sCONST\schar\s*path)/*\sPathname\sof\sfile\sto\sbe\sremoved\s(native).\s*/\n\s\s{\n!\s\s\s\s\sif\s(unlink(path)\s!=\s0\s&&\serrno\s!=\sENOENT)\s{/*\sINTL:\sNative.\s*/\n\s\sreturn\sTCL_ERROR;\n\s\s\s\s\s\s}\n\s\s\s\s\s\sreturn\sTCL_OK;\n\nDiff\sfinished.\s\sMon\sDec\s\s8\s15:12:04\s2008\n\npatches\sfor\swindows\s&\smac\s?
J foundin obsolete:\s8.5.5
J is_private 0
J priority 5\sMedium
J resolution None
J status Open
J submitter ralfixx
J subsystem 37.\sFile\sSystem
J title file\sdelete\sreports\san\serror\son\snon-existent\sfile
J type Bug
K 2406596fffffffffffffffffffffffffffffffff
U ralfixx
Z 0d7e9164f26e857211630841052ee532