0

I know this has been asked a lot but in most cases the answers were non quite satisfying/working, so I'll try to give it another shot:

In my C++ project which is being built by Eclipse CDT using MinGW with GCC, I have the following pre- and post-build steps:

  • pre: delete myapp.exe from central "dist" folder (in case an old version is lying around)
  • build: compile myapp.exe
  • post: move the compiled myapp.exe from the configuration's folder to central "dist"

So far so good, but here's the problem:

When I quickly recompile the application the delete and move/overwrite steps (pre and post) fail with a "permission denied" message. However, after a while the file is gone so I assume some delete command is waiting in the background until the permission is granted.

This is quite annoying, especially since I can't just make a change, recompile and test.

The answers I found so far mostly consist of the following:

  • the application might still be running
    -> I never started it after compiling, so I guess it's not running
  • some other application might hold a handle to the file
    -> ProcessExplorer doesn't find any open file handle to myapp.exe (though there might be one, but how would I find it?)
  • some antivirus might be checking the new file
    -> I specifically put the "dist" folder on the ignored pathI
  • the permissions might be missing
    -> I'm trying this as administrator, so user permissions should not be an issue

Any ideas of what additional things I could check?

Btw, I'm doing this on a Win7 machine, in case it does matter.

Update:

I tried to compile the app twice and then tried to delete the exe on the command line. Message: permission denied.

Here's the Process Monitor output (command was D:\Development\dist>del myapp.exe):

23:46:16,6973545    cmd.exe 3716    QueryOpen   D:\Development\dist\myapp.exe   DELETE PENDING  
23:46:16,6974731    cmd.exe 3716    QueryOpen   D:\Development\dist\myapp.exe   DELETE PENDING  
23:46:16,6975989    cmd.exe 3716    CreateFile  D:\Development\dist SUCCESS Desired Access: Read Data/List Directory, Synchronize, Disposition: Open, Options: Directory, Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
23:46:16,6976533    cmd.exe 3716    QueryDirectory  D:\Development\dist\myapp.exe   SUCCESS Filter: myapp.exe, 1: myapp.exe
23:46:16,6977718    cmd.exe 3716    CreateFile  D:\Development\dist\myapp.exe   DELETE PENDING  Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
23:46:16,6978960    cmd.exe 3716    CreateFile  D:\Development\dist\myapp.exe   DELETE PENDING  Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
23:46:16,7655834    cmd.exe 3716    QueryDirectory  D:\Development\dist NO MORE FILES   
23:46:16,7656301    cmd.exe 3716    CloseFile   D:\Development\dist SUCCESS 

So it seems as if the file is blocked because a delete is pending. I'll check the pre-build command tomorrow.

Thomas
  • 87,414
  • 12
  • 119
  • 157
  • Do you have a virus checker? If so, try turning that off. – Greg Hewgill Oct 06 '14 at 20:57
  • Try disabling your AV altogether to make sure it's not interfering. Also, you might use Process Monitor to try to see what error code Windows is returning when the delete/move operation fails. – Michael Burr Oct 06 '14 at 20:58
  • 1
    Along the same lines as the antivirus bullet, just hitching up the dist folder will often not seal the deal. Adding the compiler toolset to a list of low-risk (i.e. unscanned activity) processes is often done as well (in particular, any compiler, resource compiler, linker, and manifest tools in use). – WhozCraig Oct 06 '14 at 20:59
  • Avast is kind of famous for interfering with such steps. – Marco A. Oct 06 '14 at 21:04
  • I just tried deactivating AV (it seems to be deactivated, at least I turned off whatever options I found, AV, Malware checker, Firewall etc.) but no effect. The permission is still denied. – Thomas Oct 06 '14 at 21:07
  • Btw, the AV in use is Bitdefender IS 2015. AFAIK I can't kill the process so I deactivated whatever function I was able to deactivate. As a result both Bitdefender and Windows are complaining heavily about severe protection issues, so I assume AV is really turned off. – Thomas Oct 06 '14 at 21:13
  • See this SO question for a possible explanation and solution: http://stackoverflow.com/questions/3764072/c-win32-how-to-wait-for-a-pending-delete-to-complete – Michael Burr Oct 06 '14 at 21:52

0 Answers0