Extension Installer Catch 22

php.internals

Michael B Allen

20 years ago
I'm writing an extension installer. I want to write the installer in PHP. This presents a problem if the extension was previously installed and is automatically being loaded because it can segfault after overwriting the .so module file. Can someone recommend a method to avoid this? I can think of a few: 1) Use the -c argument to php to load a custom minimalistic php.ini file that does load the extension being installed. The downside to this is that I would like to detect within the installer if the extension is already installed and is being loaded automatically. 2) Use -d installer=yes to enable the extension to detect when it is being loaded by the installer and return FALSE to indicate the extension was not loaded. The downside to this is that a warning is printed if the modudule initialization routine fails to load. Any other ideas? Thanks, Mike
-- Michael B Allen PHP Extension for SSO w/ Windows Group Authorization http://www.ioplex.com/

Stefan Esser

20 years ago
Hello Michael,
> I'm writing an extension installer. I want to write the installer in > PHP. This presents a problem if the extension was previously installed and > is automatically being loaded because it can segfault after overwriting > the .so module file. >
IIRC, the correct way to replace .so files is to unlink() them first and then write the new file into place. Greetings, Stefan

Michael B Allen

20 years ago
On Sat, 10 Jun 2006 19:18:56 +0200 Stefan Esser <sesser@php.net> wrote:
> Hello Michael, > > I'm writing an extension installer. I want to write the installer in > > PHP. This presents a problem if the extension was previously installed and > > is automatically being loaded because it can segfault after overwriting > > the .so module file. > > > > IIRC, the correct way to replace .so files is to unlink() them first and > then write the new file into place.
Bingo. That works perfectly. So 'copy' truncates. If you 'unlink' first you get a new inode and I guess the old module is copy-on-write'd. Thanks, Mike
-- Michael B Allen PHP Extension for SSO w/ Windows Group Authorization http://www.ioplex.com/