file-locking

Powershell - Check if file is finished writing

喜欢而已 提交于 2019-12-23 20:26:05
问题 I have a powershell code that acts as a file listener on a given folder path. The listener kicks off a command line call to another program that opens and plays with the file. The problem is that the powershell code Immediately kicks off the command line call if any file is put into this folder. This is a problem if the file is very large (say 100+mb) because when a person copies the file into the folder, the file may only be 5% done 'writing' when the command function kicks off and tries to

Python: Opening a file without creating a lock

痞子三分冷 提交于 2019-12-23 11:58:36
问题 I'm trying to create a script in Python to back up some files. But, these files could be renamed or deleted at any time. I don't want my script to prevent that by locking the file; the file should be able to still be deleted at any time during the backup. How can I do this in Python? And, what happens? Do my objects just become null if the stream cannot be read? Thank you! I'm somewhat new to Python. 回答1: As mentioned by kindall, this is a Windows-specific issue. Unix OSes allow deleting. To

Preventing simultaneous db table row access

对着背影说爱祢 提交于 2019-12-23 05:33:03
问题 It sometimes happens that two admins in our support team are trying to do the same sensitive operation on db table row (let's say, modifying the value in the row). We need to prevent that. (Row locking is not possible because tables are "myisam") I have thought of several solutions: setting the old value in the form and comparing it with the current one on submit <input name="money"><input type="hidden" name="old_money" value="10"> and then before updating: $currentmoney=value_from_query(

File locked by which process?

久未见 提交于 2019-12-22 03:48:06
问题 Is there a way in .Net to find out exactly which process has locked a file? EDIT : I'm doing this because I want to let my user know that they can't modify/open the file, because at the moment, another program they're using (such as Excel) has it open. Hopefully, this helps. 回答1: The short answer to this is no. However, the long answer is that there are various API calls and WMI methods that you can use to find this information out, but don't expect it to be quick and simple. If you want to

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

南楼画角 提交于 2019-12-20 02:56:29
问题 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 device

Remove file locked by another process

杀马特。学长 韩版系。学妹 提交于 2019-12-19 10:43:39
问题 While testing an application stability I am trying to remove/corrupt database used by the application. OS is Windows, file system is NTFS, tests language is C++. What I need is to paste anything into the database file or remove it. But it is locked by the tested application during the run. So maybe someone faced this case before and you can give me/us an example on possible ways to bypass this lock in test code? Theory or source - I am appreciated for any kind of help. 回答1: You'll have to

Remove file locked by another process

最后都变了- 提交于 2019-12-19 10:43:21
问题 While testing an application stability I am trying to remove/corrupt database used by the application. OS is Windows, file system is NTFS, tests language is C++. What I need is to paste anything into the database file or remove it. But it is locked by the tested application during the run. So maybe someone faced this case before and you can give me/us an example on possible ways to bypass this lock in test code? Theory or source - I am appreciated for any kind of help. 回答1: You'll have to

How to find out which thread is locking a file in java?

百般思念 提交于 2019-12-19 06:44:08
问题 I'm trying to delete a file that another thread within my program has previously worked with. I'm unable to delete the file but I'm not sure how to figure out which thread may be using the file. So how do I find out which thread is locking the file in java? 回答1: I don't have a straight answer (and I don't think there's one either, this is controlled at OS-level (native), not at JVM-level) and I also don't really see the value of the answer (you still can't close the file programmatically once

Lock file when writing to it from parallel processes in R

瘦欲@ 提交于 2019-12-19 06:16:12
问题 I use parSapply() from parallel package in R. I need to perform calculations on huge amount of data. Even in parallel it takes hours to execute, so I decided to regularly write results to a file from clusters using write.table() , because the process crashes from time to time when running out of memory or for some other random reason and I want to continue calculations from the place it stopped. I noticed that some lines of csv files that I get are just cut in the middle, probably as a result

Is a move operation in Unix atomic?

梦想的初衷 提交于 2019-12-18 12:14:38
问题 This question was migrated from Computer Science Stack Exchange because it can be answered on Stack Overflow. Migrated 6 years ago . Suppose there are 2 processes P1 and P2, and they access a shared file Foo.txt . Suppose P2 is reading from Foo.txt . I don't want P1 to write to Foo.txt while P2 is reading it. So I thought I could make P1 write to Foo.tmp and as a last step, rename Foo.tmp to Foo.txt . My programming language is Java So my question is, would this ensure that P2 reads the