On Sun, Aug 13, 2023 at 7:13 PM Martin Wege <martin.l.w...@gmail.com> wrote: > > On Sun, Aug 13, 2023 at 12:43 AM Roland Mainz via Cygwin > <cygwin@cygwin.com> wrote: > > > > On Fri, Aug 11, 2023 at 10:55 AM Corinna Vinschen via Cygwin > > <cygwin@cygwin.com> wrote: > > [snip] > > > On Aug 11 10:25, Martin Wege wrote: > > > > Cygwin somehow breaks unmounting of network shares, but ONLY if the > > > > net use /delete happens in a bash shell script. > > > > > > > > Example: > > > > Mount SMB network share on Z: > > > > Do not touch Z:! > > > > > > > > Then do a net use /delete in a bash script: > > > > net use Z: /delete > > > > Systemfehler 1794 aufgetreten. > > > > Der Redirector wird verwendet und kann nicht aus dem Speicher entfernt > > > > werden. > > > > > > > > If I execute the net use Z: /delete in an interactive bash shell it > > > > works. > > > > > > > > Can anyone explain this? > > > > > > Something is wrong on your side, but no, I can't explain it. It's > > > not related to Cygwin: > > > > > > $ cat > b.sh <<EOF > > > #!/bin/bash > > > net use Z: /delete > > > EOF > > > $ chmod +x b.sh > > > $ net use Z: \\\\server\\share > > > The command completed successfully. > > > > > > B:[~]$ ./b.sh > > > Z: was deleted successfully. > > > > I think it's the problem that a shell keeps a fd open to the shell > > script's file. > > > > Example: > > ---- snip ---- > > $ cat shellfd.ksh > > #!/bin/ksh93 > > # shell script printing the fd which the shell > > # process has open right now > > ls -l /proc/$$/fd/ > > true # needed here so ksh93 doesn't make a tail optimisation > > exit 0 > > $ bash shellfd.ksh > > total 0 > > lrwx------ 1 test001 users 64 Aug 13 00:26 0 -> /dev/pts/7 > > lrwx------ 1 test001 users 64 Aug 13 00:26 1 -> /dev/pts/7 > > lrwx------ 1 test001 users 64 Aug 13 00:26 2 -> /dev/pts/7 > > lr-x------ 1 test001 users 64 Aug 13 00:26 255 -> > > /cygdrive/h/tmp/shellfd.ksh > > $ ksh93 shellfd.ksh > > total 0 > > lrwx------ 1 test001 users 64 Aug 13 00:26 0 -> /dev/pts/7 > > lrwx------ 1 test001 users 64 Aug 13 00:26 1 -> /dev/pts/7 > > lr-x------ 1 test001 users 64 Aug 13 00:26 10 -> /cygdrive/h/tmp/shellfd.ksh > > lrwx------ 1 test001 users 64 Aug 13 00:26 2 -> /dev/pts/7 > > ---- snip ---- > > > > So both bash4 an ksh93 keep a fd to the shell script ("shellfd.ksh") > > around (I even tried /usr/bin/shcomp to make shell bytecode, but the > > issue remains...) > > > > And here comes the nasty part: If shellfd.ksh is on a network > > filesystem (in my test setup my home dir, mounted at H:), then in some > > cases (I do not know why) a $ net use Z: /delete # will fail with > > error #1794 if both network filesystems are from the same server. > > > > This is NOT the same as the script tries to unmount the filesystem it > > is residing on - Z: is mounted separately, and a different exported > > directory than H:, and yet I can reproduce that issue (after around > > 30-40 experiments, until I remembered that ksh93 keeps a fd to the > > script open). > > > > This sounds a lot like a Windows bug. > > > > Martin: Do you have more than one network filesystem mounted on your > > machine ? > > Yes, usually 12-14 filesystems mounted per machine. This includes user > directories, and several directories where the software and production > data come from. I still have to test whether putting software on a > local disk solves the problem. Maybe I should better call this a > workaround for a silly Windows restriction.
Yeah, putting software on a local disk allows me to do a successful net use Z: /delete So what do we do now? File a bug at Microsoft support, and they fix that for Windows 12 in 2038? Thanks, Martin -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple