Skip to content

"Another program is currently running this file" #478

Closed

Description

@arcanis

Right after cross-compiling a binary for Windows, I find myself unable to run it with the error mentionned above. This error persists even after closing Bash, and the file handler isn't detected by Process Explorer. As a workaround, I can copy the file anywhere else, and it will run fine.

Activity

  1. sunilmut commented on Jun 6, 2016

    @sunilmut
    Member

    Maël Nison (@arcanis) - I am not clear on your scenario. Are you trying to run a win32\64 PE binary within WSL? WSL currently only supports executing ELF64 binaries.

  2. jamesdavidhoward commented on Jun 21, 2016

    @jamesdavidhoward

    Sunil Muthuswamy (@sunilmut) - In gcc/g++ in WSL (and other compilation tools), one can build a PE+ binary. If it is placed in a location that one's "normal" Windows cmd.exe (or other) can see the just-built executable, it should be able to be run. This problem is likely due to a (severe) delay between WSL recognizing a file is closed after being written to an NTFS file system, and flushing the file system data to the Windows subsystem. I've seen situations where the file is seen as "still open", or even it is completely absent (until time or a re-login occur). A disappointment.

  3. aseering commented on Jun 21, 2016

    @aseering
    Contributor

    jamesdavidhoward -- is your output file being written to a directory under /mnt/, or to the Linux internal filesystem? (Not quite sure what you mean by "a location that one's "normal" Windows ... can see")

  4. jamesdavidhoward commented on Jun 21, 2016

    @jamesdavidhoward

    The file system update - think "flush & sync" - inconsistency occurs when
    creating, manipulating or deleting a file underneath /mnt/ -
    /mnt/c/Users/..., for example. When that directory is also viewed by,
    say, WindowsFile Explorer - even after an Explorer [Refresh] operation.
    It is completely unacceptable for there to be any more delay in finalizing
    NTFS metadata and data than would be experienced by a Windows PE+
    executable manipulating a file.

    The reverse is also true: a Windows PE executable manipulating a file or
    directory in the WSL subsystem.

    SFU had no problem in this regard; why does WSL?


    James D. Howard, [email protected]

  5. aseering commented on Jun 22, 2016

    @aseering
    Contributor

    jamesdavidhoward -- could you post a specific reproducer? I'm not seeing that delay on my system. I don't work on the WSL team, but my understanding of their architecture is that it is intended to do exactly what you're asking for. (Which, I agree, is very important.)

    The following command works for me, and would seem to indicate that a file written by WSL is in fact visible ~immediately from native Windows):

    c:\Users\[my homedir]> bash.exe -c "gcc /mnt/c/Users/%USERNAME%/tmp.c -o /mnt/c/Users/%USERNAME%/tmp" && dir /b tmp
    tmp
    

    My "tmp.c" contained the following, for reference:

    #include <stdio.h>
    int main() {
    printf("hi!\n");
    return 0;
    }
    

    If I replace dir /b tmp with type tmp, I get a pile of ELF goo back (which I won't attempt to paste into github). If I run the gcc command in a WSL window, then (with the WSL window still open) run the dir command at a Windows shell, the file also appears immediately for me.

    Are you running a third-party Windows antivirus program? Maybe one that is not aware of WSL? If I were an antivirus program, and I saw a bunch of Windows executable content appearing on the machine apparently out of nowhere, I would be scanning that stuff as aggressively as possible; locking it, possibly quarantining it, etc.

    You refer to Windows Explorer a lot: Explorer is many layers of abstraction above the actual physical storage. Is it possible that you have an Explorer plugin on your machine that's misbehaving?

  6. jamesdavidhoward commented on Jun 26, 2016

    @jamesdavidhoward

    Experimenting with these scenarios subsequent to update to build 14372, and then lxrun /uninstall, then lxrun /install, the situation is greatly improved. The one remaining long delay is the following:

    • Open bash shell, cd to one's $HOME
    • Open File Explorer (I've no 3rd-party add-ins, yet, since they often screw up in Windows 10), and navigate to %HOMEDRIVE%%HOMEPATH%\AppData\Local\lxss\home\%USERNAME%
    • bash: "touch WSLfile"
    • Explorer: empty file appears
    • Explorer: select WSLfile and [Shift Right Click] delete it
    • visibly gone from Explorer
    • visibly gone from CMD.EXE shellcd'd to same place
    • still present in bash shell ls
      ... wait a couple of minutes
    • now gone everywhere.

    Not running 3rd-party anti-virus: running Defender
    Not running and non-MSFT File Explorer extensions. example: do have "Scan with Defender: context menu extension...

  7. benhillis commented on Jun 27, 2016

    @benhillis
    Member

    jamesdavidhoward - Thanks for the detailed explanation of what you're seeing. The user home directory is a VolFs mount which doesn't handle concurrent use between NT and WSL very well. For now if you want to access files from both NT and WSL I'd suggest using a DriveFs path (somewhere under one of your drive mounts /mnt/*). This is definitely something we'll be working on improving in future releases.

    We have a video explaining the differences between VolFs and DriveFs as well as a blog post if you prefer that format.

  8. therealkenc commented on Dec 5, 2017

    @therealkenc

    Discussion ran course last year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions