file-locking

How to prevent file locking when undeploying a Tomcat web app?

℡╲_俬逩灬. 提交于 2019-11-27 09:03:31
问题 I am using the manager app in tomcat 7, and i am unable to undeploy an application completely. It says FAIL - Unable to delete [F:\apache-tomcat-7.0.33\webapps\balaji]. The continued presence of this file may cause problems. I read somewhere its because of some phenomenon called memory leak , and if we fix it the issue will be solved. Can anyone tell me what is this memory leak in tomcat 7, and how can we fix it ?? I am using windows 7 OS. If i am able to fix it will my un-deploy and re

Test if file is locked

淺唱寂寞╮ 提交于 2019-11-27 02:30:02
问题 In PHP, how can I test if a file has already been locked with flock? For example, if another running script has called the following: $fp = fopen('thefile.txt', 'w'); flock($fp, LOCK_EX); 回答1: if (!flock($fp, LOCK_EX|LOCK_NB, $wouldblock)) { if ($wouldblock) { // another process holds the lock } else { // couldn't lock for another reason, e.g. no such file } } else { // lock obtained } As described in the docs, use LOCK_NB to make a non-blocking attempt to obtain the lock, and on failure

Java FileLock for Reading and Writing

非 Y 不嫁゛ 提交于 2019-11-27 01:48:43
问题 I have a process that will be called rather frequently from cron to read a file that has certain move related commands in it. My process needs to read and write to this data file - and keep it locked to prevent other processes from touching it during this time. A completely separate process can be executed by a user to (potential) write/append to this same data file. I want these two processes to play nice and only access the file one at a time. The nio FileLock seemed to be what I needed

How can I unlock a file that is locked by a process in .NET [duplicate]

删除回忆录丶 提交于 2019-11-27 01:37:05
问题 This question already has an answer here: Unlock Files for deletion 2 answers I want my application to clean all the temp files it used, the problem is that not all the temp files are under my control, so I just want to "brutally" unlock them in order to delete them programatically. 回答1: Take a look at this article. I think that you'll struggle to do this in C# natively, even using interop, but writing a C++/CLI wrapper assembly may be a good compromise. Note also that the user needs to have

Reading a file used by another process [duplicate]

耗尽温柔 提交于 2019-11-26 17:37:42
This question already has an answer here: How can I read a file even when getting an “in use by another process” exception? 4 answers I am monitoring a text file that is being written to by a server program. Every time the file is changed the content will be outputted to a window in my program. The problem is that I can't use the Streamreader on the file as it is being used by another process . Setting up a Filestream with ReadWrite won't do any good since I cannot control the process that is using the file. I can open the file in notepad. It must be possible to access it even though the

How do I delete a file which is locked by another process in C#?

青春壹個敷衍的年華 提交于 2019-11-26 17:33:50
I'm looking for a way to delete a file which is locked by another process using C#. I suspect the method must be able to find which process is locking the file (perhaps by tracking the handles, although I'm not sure how to do this in C#) then close that process before being able to complete the file delete using File.Delete() . Ishmaeel Killing other processes is not a healthy thing to do. If your scenario involves something like uninstallation, you could use the MoveFileEx API function to mark the file for deletion upon next reboot. If it appears that you really need to delete a file in use

How do I delete a file which is locked by another process in C#?

末鹿安然 提交于 2019-11-26 05:29:39
问题 I\'m looking for a way to delete a file which is locked by another process using C#. I suspect the method must be able to find which process is locking the file (perhaps by tracking the handles, although I\'m not sure how to do this in C#) then close that process before being able to complete the file delete using File.Delete() . 回答1: Killing other processes is not a healthy thing to do. If your scenario involves something like uninstallation, you could use the MoveFileEx API function to mark

Is there a way to check if a file is in use?

。_饼干妹妹 提交于 2019-11-25 22:53:44
问题 I\'m writing a program in C# that needs to repeatedly access 1 image file. Most of the time it works, but if my computer\'s running fast, it will try to access the file before it\'s been saved back to the filesystem and throw an error: \"File in use by another process\" . I would like to find a way around this, but all my Googling has only yielded creating checks by using exception handling. This is against my religion, so I was wondering if anyone has a better way of doing it? 回答1: Updated

Locking a file in Python

 ̄綄美尐妖づ 提交于 2019-11-25 22:34:08
问题 I need to lock a file for writing in Python. It will be accessed from multiple Python processes at once. I have found some solutions online, but most fail for my purposes as they are often only Unix based or Windows based. 回答1: Alright, so I ended up going with the code I wrote here, on my website link is dead, view on archive.org (also available on GitHub). I can use it in the following fashion: from filelock import FileLock with FileLock("myfile.txt"): # work with the file as it is now

How do I find out which process is locking a file using .NET?

你说的曾经没有我的故事 提交于 2019-11-25 21:58:05
问题 I\'ve seen several of answers about using Handle or Process Monitor, but I would like to be able to find out in my own code (C#) which process is locking a file. I have a nasty feeling that I\'m going to have to spelunk around in the win32 API, but if anyone has already done this and can put me on the right track, I\'d really appreciate the help. Update Links to similar questions How does one figure out what process locked a file using c#? Command line tool Across a Network Locking a USB