# Extension Installer Catch 22

- Thread: https://externals.io/message/24080
- Original archive: https://news-web.php.net/php.internals/24080
- Started by Michael B Allen on 2006-06-10T17:14:59+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #24080 — Michael B Allen — 2006-06-10T17:14:59+00:00

URL: https://externals.io/message/24080#24080

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/

---

## #24081 — Stefan Esser — 2006-06-10T17:18:56+00:00

URL: https://externals.io/message/24080#24081 · In reply to: #24080

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

---

## #24082 — Michael B Allen — 2006-06-10T18:14:44+00:00

URL: https://externals.io/message/24080#24082 · In reply to: #24081

On Sat, 10 Jun 2006 19:18:56 +0200
Stefan Esser <sesser@php.net> wrote:

> Hello Michael,
> > […]
> 
> 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/
