Re: Replacing setup.exe and cygcheck with dpkg (Was: Re: cygcheck typo in both manpage and --help)

2009-03-10 Thread Corinna Vinschen
On Mar  9 19:08, Sjors Gielen wrote:
> I think I checked how Cygwin implements fork() a while ago, can't really  
> remember though. But on a fork(), do processes inherit all information  
> on dll's, et cetera? Or do they reload the dll and re-check the  
> addresses of entry points and all?

Very basically, the executable is started again via CreateProcess, then
Cygwin copies the parent's data segments into the child.  The important
faxct here is that the actual load process of the child is done by the
Windows loader.  If you changed the Cygwin DLL in the meantime, the new
process will load the new Cygwin DLL, not the old one.  From there it
goes downhill because the data layout of the new DLL is different from
the layout in the old DLL loaded with the parent process.

> I *think* this cygfoo1_2_3.dll system does not work with the Cygwin dll  
> itself, because that all still happens completely outside of Cygwin  
> scope

Yes.  This happens because we're using Windows API and thus Windows
loader to load processes.  The Windows API simply hasn't been designed
to fork.  That's why Cygwin has to do all the tricky and not very
performant stuff before and after loading a process.  Actually the
native NT API is capable to fork a process and that's used, for
instance, in Interix.  However, Interix is its entire self-contained
POSIX subsystem, distinct from Windows, while Cygwin processes are
running inside of the Windows subsystem.  Unfortunately important parts
of the API used to attach a new process to the Windows subsystem are not
documented.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat

--
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/



Re: Replacing setup.exe and cygcheck with dpkg (Was: Re: cygcheck typo in both manpage and --help)

2009-03-09 Thread Sjors Gielen

Christopher Faylor schreef:

Right.  And that has been the main reason why writing an installer which
uses Cygwin is problematic.

I've been using the "rename the dll or executable" technique for about ten
years to install a newly-compiled version of cygwin1.dll on a system with
a running version of cygwin.  However, this hoses any running processes
and it even makes running any cygwin processes flaky until all processes
which use the old DLL have been shut down.

cgf



You're right. Any testing I've done until now regarding replacing files, 
did include replacing the Cygwin DLL, but it didn't include replacing 
the Cygwin DLL with a *different version* of the DLL.


I think I checked how Cygwin implements fork() a while ago, can't really 
remember though. But on a fork(), do processes inherit all information 
on dll's, et cetera? Or do they reload the dll and re-check the 
addresses of entry points and all?


Something I'm wondering about: When you build something against 
libfoo.so on Linux, usually you actually link against libfoo.1.2.3 
because of the symlinks. I've seen cygfoo1_2_3.dll if I remember 
correctly - what about never having to replace dlls? This leaves the 
problem of replacing a Cygwin dll, but this is the only "special" DLL I 
think. Maybe there should be some kind of background daemon that's fired 
up when cygwin1.dll needs to be replaced. It then just puts itself in 
the systray, and when hovered it just says "Hey, maybe you want to 
reboot sometime soon to have me reload your Cygwin dll..." Then when all 
Cygwin processes are stopped, or the system reboots (which is the same), 
the dll is automatically replaced.


I *think* this cygfoo1_2_3.dll system does not work with the Cygwin dll 
itself, because that all still happens completely outside of Cygwin 
scope, so no linking cygwin1.dll to anything. I'm not at all an expert 
on these matters, though.


Sjors

--
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/



Re: Replacing setup.exe and cygcheck with dpkg (Was: Re: cygcheck typo in both manpage and --help)

2009-03-09 Thread Christopher Faylor
On Mon, Mar 09, 2009 at 11:21:52AM +0100, Corinna Vinschen wrote:
>On Mar  9 09:55, Andy Koppe wrote:
>> Spiro Trikaliotis:
>> > You can replace a running exe (or dll) by doing the following:
>> >
>> > 1. rename the .DLL or .EXE
>> 
>> Are you sure that's possible? I'd expect Windows to complain loudly at
>> that point.
>
>You can in theory, but that won't work reliably for subsequent Cygwin
>processes.  If you replace a running processes' executable with a new
>release, and if that process is one of the forking kind, every
>subsequent call to fork() will break.  If you replace the Cygwin DLL
>with a new release on the fly, then *any* subsequent fork() will almost
>surely break.

Right.  And that has been the main reason why writing an installer which
uses Cygwin is problematic.

I've been using the "rename the dll or executable" technique for about ten
years to install a newly-compiled version of cygwin1.dll on a system with
a running version of cygwin.  However, this hoses any running processes
and it even makes running any cygwin processes flaky until all processes
which use the old DLL have been shut down.

cgf

--
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/



Re: Replacing setup.exe and cygcheck with dpkg (Was: Re: cygcheck typo in both manpage and --help)

2009-03-09 Thread Corinna Vinschen
On Mar  9 10:18, Marco Atzeri wrote:
> --- Lun 9/3/09, Andy Koppe ha scritto:
> > Are you sure that's possible? I'd expect Windows to
> > complain loudly at
> > that point.
> > [...]
> I also used that trick to replace cyglsa.dll installing
> snapshots but cyglsa.dll was not in use at that time.

It's safe to do for cyglsa.dll.  Windows accesses this DLL by handle
and the replacement is only used after a reboot.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat

--
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/



Re: Replacing setup.exe and cygcheck with dpkg (Was: Re: cygcheck typo in both manpage and --help)

2009-03-09 Thread Corinna Vinschen
On Mar  9 09:55, Andy Koppe wrote:
> Spiro Trikaliotis:
> > You can replace a running exe (or dll) by doing the following:
> >
> > 1. rename the .DLL or .EXE
> 
> Are you sure that's possible? I'd expect Windows to complain loudly at
> that point.

You can in theory, but that won't work reliably for subsequent Cygwin
processes.  If you replace a running processes' executable with a new
release, and if that process is one of the forking kind, every
subsequent call to fork() will break.  If you replace the Cygwin DLL
with a new release on the fly, then *any* subsequent fork() will almost
surely break.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat

--
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/



Re: Replacing setup.exe and cygcheck with dpkg (Was: Re: cygcheck typo in both manpage and --help)

2009-03-09 Thread Marco Atzeri

--- Lun 9/3/09, Andy Koppe ha scritto:

> Da: Andy Koppe 
> Oggetto: Re: Replacing setup.exe and cygcheck with dpkg (Was: Re: cygcheck   
> typo in both manpage and --help)
> A: cygwin@cygwin.com
> Data: Lunedì 9 marzo 2009, 10:55
> Spiro Trikaliotis:
> > You can replace a running exe (or dll) by doing the
> following:
> >
> > 1. rename the .DLL or .EXE
> 
> Are you sure that's possible? I'd expect Windows to
> complain loudly at
> that point.
> 
> Andy
> 

It is not feasible for cygwin1.dll, you can change the name 
and M$ will not complain but any following action 
will crash for a program based on
cygwin1.dll.

$ mv cygwin1.dll cygwin1.dll_test

$ ls
  3 [main] bash 2660 fork: child -1 - died waiting for longjmp before 
initialization, retry 10, exit code 0xC135, errno 11

bash: fork: Resource temporarily unavailable


I also used that trick to replace cyglsa.dll installing
snapshots but cyglsa.dll was not in use at that time.



Regards
Marco


__
Do You Yahoo!?
Poco spazio e tanto spam? Yahoo! Mail ti protegge dallo spam e ti da tanto 
spazio gratuito per i tuoi file e i messaggi 
http://mail.yahoo.it

--
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/



Re: Replacing setup.exe and cygcheck with dpkg (Was: Re: cygcheck typo in both manpage and --help)

2009-03-09 Thread Andy Koppe
Spiro Trikaliotis:
> You can replace a running exe (or dll) by doing the following:
>
> 1. rename the .DLL or .EXE

Are you sure that's possible? I'd expect Windows to complain loudly at
that point.

Andy

--
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/



Re: Replacing setup.exe and cygcheck with dpkg (Was: Re: cygcheck typo in both manpage and --help)

2009-03-08 Thread Spiro Trikaliotis
Hello,

* On Sun, Mar 08, 2009 at 09:45:39PM -0400 Christopher Faylor wrote:
> On Mon, Mar 09, 2009 at 12:42:31AM +0100, Sjors Gielen wrote:
> > (Since 1.7 already fixes the problem of installing running programs,
> 
> Color me dubious.  How did you solve the problem of installing cygwin over
> a running version of cygwin?

You can replace a running exe (or dll) by doing the following:

1. rename the .DLL or .EXE

2. put the new .DLL or .EXE into place

Once the program holding the .DLL or .EXE quits, you can remove the
renamed versions. This can be done on the next boot, for example.

Best regards,
Spiro.

-- 
Spiro R. Trikaliotis  http://opencbm.sf.net/
http://www.trikaliotis.net/ http://www.viceteam.org/

--
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/



Re: Replacing setup.exe and cygcheck with dpkg (Was: Re: cygcheck typo in both manpage and --help)

2009-03-08 Thread Christopher Faylor
On Mon, Mar 09, 2009 at 12:42:31AM +0100, Sjors Gielen wrote:
> Christopher Faylor schreef:
>>> setup.exe and cygcheck are very nice but was wondering if the idea of 
>>> using
>>> yum and rpm was ever tossed around?
>> Yes, it has been discussed many times.  There are big barriers to
>> getting these working, mainly due to problems installing already-running
>> programs.
>> cgf
>
> Hey Christopher,
>
> I've succesfully ported dpkg. In a few weeks time, I'll start working on my 
> Debian Cygwin project again, I'm currently busy with other things - but 
> maybe you could take a look at my dpkg changes and see if you can make a 
> Cygwin-dpkg which is compatible with cygcheck and setup.exe. Dpkg is very 
> easy to use, as is apt-get which I was busy porting before I stopped 
> temporarily.

Sorry but I don't see us moving to dpkg.  If we were going to use
anything it would probably be rpm.  Cygwin is owned by Red Hat and
hosted on a Red Hat sponsored system after all.

> (Since 1.7 already fixes the problem of installing running programs,

Color me dubious.  How did you solve the problem of installing cygwin over
a running version of cygwin?

cgf

--
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/



Replacing setup.exe and cygcheck with dpkg (Was: Re: cygcheck typo in both manpage and --help)

2009-03-08 Thread Sjors Gielen

Christopher Faylor schreef:

setup.exe and cygcheck are very nice but was wondering if the idea of using
yum and rpm was ever tossed around?


Yes, it has been discussed many times.  There are big barriers to
getting these working, mainly due to problems installing already-running
programs.

cgf


Hey Christopher,

I've succesfully ported dpkg. In a few weeks time, I'll start working on 
my Debian Cygwin project again, I'm currently busy with other things - 
but maybe you could take a look at my dpkg changes and see if you can 
make a Cygwin-dpkg which is compatible with cygcheck and setup.exe. Dpkg 
is very easy to use, as is apt-get which I was busy porting before I 
stopped temporarily.
(Since 1.7 already fixes the problem of installing running programs, 
there are only two important changes: multiple slashes at the beginning 
of a path are mapped to one, and when installing a new binary dpkg uses 
vfork() instead of fork() for the one corner case where dpkg re-installs 
itself.)
If you want them, I'll upload the patches to the subversion repository 
of the project as soon as I can. They are currently sleeping on my disk 
until the project gets far enough to release some binaries and sources.


Sjors

--
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/