Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 76373CCF7 for ; Wed, 17 Jul 2013 13:16:44 +0000 (UTC) Received: (qmail 1823 invoked by uid 500); 17 Jul 2013 13:16:39 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 1426 invoked by uid 500); 17 Jul 2013 13:16:37 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 1416 invoked by uid 99); 17 Jul 2013 13:16:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Jul 2013 13:16:35 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [194.25.134.82] (HELO mailout05.t-online.de) (194.25.134.82) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Jul 2013 13:16:29 +0000 Received: from fwd17.aul.t-online.de (fwd17.aul.t-online.de ) by mailout05.t-online.de with smtp id 1UzRaO-0001Aq-7M; Wed, 17 Jul 2013 15:16:04 +0200 Received: from NamePC (VT9kUrZ1rhKjCtmrAojPA-4alpp6J6CVeTO26TNGy-XsY-HRdx4xqeylpug3bTIZzX@[93.197.187.190]) by fwd17.t-online.de with esmtp id 1UzRaB-0HUFqC0; Wed, 17 Jul 2013 15:15:51 +0200 From: =?utf-8?Q?Konstantin_Prei=C3=9Fer?= To: "'Tomcat Users List'" References: <51E5BE91.8010800@yahoo.com> In-Reply-To: <51E5BE91.8010800@yahoo.com> Subject: RE: [OT] Cannot cleanly undeploy a web application Date: Wed, 17 Jul 2013 15:15:38 +0200 Message-ID: <000001ce82ef$bb73dbd0$325b9370$@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQEJyKUryDbfpLIZCuE08SsmOiKEEJryR/+A Content-Language: de X-ID: VT9kUrZ1rhKjCtmrAojPA-4alpp6J6CVeTO26TNGy-XsY-HRdx4xqeylpug3bTIZzX X-TOI-MSGID: df4d5a7e-08c8-4e9a-bc29-81057daf28e8 X-Virus-Checked: Checked by ClamAV on apache.org Hi, > From: Andr=C3=A9 Warnier [mailto:aw@ice-sa.com]=20 > Subject: Re: [OT] Cannot cleanly undeploy a web application >=20 > I believe that the underlying issue here is the difference in = behaviour between Windows=20 > and Unix/Linux, with regard to a file opened by one process, when = another process tries to > delete the file. > Unix/Linux allow this. The file entry in the directory is deleted, the = process deleting it > gets no error. The file itself is not deleted, and the process which = has it open still has > a handle to the file and can continue to access it. > Under Windows however, the process trying to delete the file gets an = error, at the very=20 > moment of the "delete". I just wanted to add something: The Unix behavior you describe is also possible under Windows. It = depends on the "file share" flag that is used to open a file. I don't know how this works in the native WinAPI, but if you try the = following C# code for example (.Net) to read from a (big) file: using (Stream s =3D new FileStream("C:\\MyBigFile.bin", FileMode.Open, = FileAccess.Read, FileShare.Delete | FileShare.Read)) { byte[] buf =3D new byte[128]; int read; while ((read =3D s.Read(buf, 0, buf.Length)) > 0) { Console.WriteLine("Read: " + read + " bytes."); Thread.Sleep(2000); // wait 2 seconds } } Then you can delete the file while it is still opened and the program = reads from it. If you look at the free space of the drive, you will see = that the space that the file uses is not yet available. As soon as you = close the process / cancel the reading, the space will become available. It seems that most programs don't open a file that way - that is why an = error occurs when trying to delete such a file. However, I don't know = why most programs (or a Java InputStream etc.) open a file for reading = without specifying such a file share flag (E.g., in the above code = example, if you use a FileStream constructor that doesn't specify a = FileShare flag, the file cannot be deleted from other processes while it = is opened). Maybe it is a design principle in Windows to not be able to = delete a opened file by default, so that a user doesn't accidentally = delete a file on which he is still working... but I don't know. Regards, Konstantin Prei=C3=9Fer --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org