delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/02/20/18:48:13

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <40369C0A.50934507@dessent.net>
Date: Fri, 20 Feb 2004 15:45:14 -0800
From: Brian Dessent <brian AT dessent DOT net>
Organization: My own little world...
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: tar and open files
References: <F67AB1DD14544242BE5BFE94F5939175B7F298 AT E2KMEMMCS1 DOT ftbco DOT ftn DOT com>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com

"DePriest, Jason R." wrote:
> 
> For a DLL, does just unregistering the DLL do what you need?  I mean,
> running 'regsvr32 /u <dll>', put new file in place, run 'regsvr32
> <dll>'?

No.  The replacement only occurs at boot-time.

I don't know if this is quite off-topic or not but I wrote the following
perl script which reads the list of Pending File Rename Operations (to
occur at next boot time) and outputs a shell script to perform them. 
Example of its use would be:

- Run setup.exe
- try to upgrade some in-use thing
- setup.exe tells you that you need to reboot because you forget to stop
all cygwin processes
- you stop all cygwin processes
- run this script, which outputs a script to perform the pending renames
without having to reboot, assuming those files are now not open
- delete the PendingFileRenameOperations registry key with regedit or
/proc/registry
- restart processes without a reboot

It requires libwin32, but you could probably modify it to use
/proc/registry as well.  Note also that it wouldn't work without
modification for replacing cygwin1.dll since it spits out a set of 'mv'
commands, and mv requires cygwin1.dll.  It's also overly complicated
since it cygwin-izes the paths.  It would have been easier to spit out
dos commands probably.  Hindsight...

Note that this does not do any magic!  It's only for the case where you
try to install or upgrade something where you forgot to stop it first. 
It won't let you magically replace inuse files, it's only for the case
where you can stop the process, but don't feel like rebooting just to
rename some files.

There's no error checking, use at your own risk, blah blah blah.

#!/usr/bin/perl -w

use Win32::TieRegistry;

my $pr =
$Registry->{'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\PendingFileRenameOperations'};

my @list = split('\0', $pr);

print "# ", join("\n# ", @list), "\n";

while (@list) {
  my $a = shift @list;
  my $b = shift @list;
  
  if ($b) {
    print "mv -f " . fix($a) . " " . fix($b) . "\n";
  } else {
    print "rm " . fix($a) . "\n";
  }
}
        
sub fix
{
  my $in = shift;
  
  $in =~ s%^\!?\\\?\?\\%%;
  my $foo = quotemeta($in);
  chomp (my $bar = `cygpath -u $foo`);
  return "\'$bar\'";
}

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019