ReleaseEngineering/How To/Remove files held open by another process on Windows

From MozillaWiki
Jump to: navigation, search

rm: cannot remove directory `build': Permission denied

I ran into a situation yesterday where a Windows 8 64-bit tester (t-w864-ix-069) was unable to remove the build dir because it was being help open by another process. I gracefully stopped the slave from the buildbot master and then did some investigation.

Connecting to the machine via VNC, I downloaded Windows Sysinternals Process Explorer from here: http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx (Direct download link: http://download.sysinternals.com/files/ProcessExplorer.zip)

Running the Process Explorer as Administrator (you can switch users by selecting "Show Details for All Processes" from the File menu), I selected Find->File Handle or DLL... I searched for the directory that was being held open, which was C:\slave\test\build. The file was being held open by KpyM, the ssh server, which was weird, but whatever. I killed off the ssh daemon, quickly removed the directory (you may need to be quick because I think the ssh daemon is setup to restart), and then rebooted the machine.