Re: fork() and dynamically loaded c functions....

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: fork() and dynamically loaded c functions....
Дата
Msg-id 21552.1281484158@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: fork() and dynamically loaded c functions....  (Jay Flattery <jaycode@rocketmail.com>)
Ответы Re: fork() and dynamically loaded c functions....  (Alvaro Herrera <alvherre@commandprompt.com>)
Re: fork() and dynamically loaded c functions....  (Jay Flattery <jaycode@rocketmail.com>)
Список pgsql-general
Jay Flattery <jaycode@rocketmail.com> writes:
>> What exactly is that child process doing?  It sure sounds like it thinks
>> it's a valid backend.

> Actually it's not doing anything, as I'm just trying to work it all out - just a

> bunch of printfs and waits.
> But the library is a PG_MAGIC_MODULE.

> I tried killing it with pg_terminate_backend(pid) - but I get WARNING:   PID
> 1166738497 is not a PostgreSQL server process. (Interestingly the  child
> pid=28629, which was printed in the line before)

The forked process still thinks it's a backend, so when you try to kill
it it's going to try to disconnect from shared memory.  This is bad,
since the parent still thinks the same thing, but the child will have
zapped the parent's entries in shared memory.

Offhand the only clean way I can see to launch a child process is to
fork *and exec something*.  There is way too much state lying around
in a backend process that could rise up to bite you if you don't.
You might find that doing on_exit_reset() in the child would fix the
worst problems, but it still sounds chancy as heck.

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: Jay Flattery
Дата:
Сообщение: Re: fork() and dynamically loaded c functions....
Следующее
От: Greg Smith
Дата:
Сообщение: Re: MySQL versus Postgres