Re: [GENERAL] Trigger that spawns forked process

2005-05-11 Thread Tom Lane
Christopher Murtagh <[EMAIL PROTECTED]> writes: > So, if I made a slight modification to my script to this instead: > CREATE or REPLACE function exec_test() returns void as ' > unless (defined ($pid=fork)) { > die "cannot fork: $!"; > } > unless ($pid) { > $cmd="/path/to/some/script.pl";

Re: [GENERAL] Trigger that spawns forked process

2005-05-11 Thread Christopher Murtagh
On Wed, 2005-05-11 at 00:08 +0200, Martijn van Oosterhout wrote: > On Tue, May 10, 2005 at 05:31:56PM -0400, Christopher Murtagh wrote: > > > I'm not sure what happens when you do "exit" here, but I'll lay odds > > > against it being exactly the right things. > > > > It ends the daemonized proces

Re: [GENERAL] Trigger that spawns forked process

2005-05-10 Thread Martijn van Oosterhout
On Tue, May 10, 2005 at 05:31:56PM -0400, Christopher Murtagh wrote: > > I'm not sure what happens when you do "exit" here, but I'll lay odds > > against it being exactly the right things. > > It ends the daemonized process, kinda like a wrapper suicide. :-) I think you have a problem here. Post

Re: [GENERAL] Trigger that spawns forked process

2005-05-10 Thread Christopher Murtagh
On Tue, 2005-05-10 at 16:17 -0400, Tom Lane wrote: > ... let's see, you already broke the backend there --- unless its normal > setting of SIGCHLD is IGNORE, in which case munging it is unnecessary > anyway ... Here's my (probably all garbled) explanation: Essentially what that code is a self-daem

Re: [GENERAL] Trigger that spawns forked process

2005-05-10 Thread Christopher Murtagh
On Tue, 2005-05-10 at 13:50 -0700, David Fetter wrote: > Why do you think Slony won't work for this? One way it could do it is > to have an ON INSERT trigger that populates one or more tables with > the result of the XSLT, which table(s) Slony replicates to the other > servers. Because the nodes

Re: [GENERAL] Trigger that spawns forked process

2005-05-10 Thread David Fetter
On Tue, May 10, 2005 at 04:02:59PM -0400, Christopher Murtagh wrote: > On Tue, 2005-05-10 at 11:11 -0500, Jim C. Nasby wrote: > > Well, LISTEN and NOTIFY are built into PostgreSQL > > (http://www.postgresql.org/docs/8.0/interactive/sql-notify.html). > > If the processes that you're trying to notify

Re: [GENERAL] Trigger that spawns forked process

2005-05-10 Thread Tom Lane
Christopher Murtagh <[EMAIL PROTECTED]> writes: > I was given an example of how to spawn a forked process with plperlu, > and it looks pretty simple and straightforward and exactly what I want: > CREATE or REPLACE function somefunc() returns void as $$ > $SIG{CHLD}='IGNORE'; ... let's see, you a

Re: [GENERAL] Trigger that spawns forked process

2005-05-10 Thread Scott Marlowe
On Tue, 2005-05-10 at 15:02, Christopher Murtagh wrote: > On Tue, 2005-05-10 at 11:11 -0500, Jim C. Nasby wrote: > > Well, LISTEN and NOTIFY are built into PostgreSQL > > (http://www.postgresql.org/docs/8.0/interactive/sql-notify.html). If the > > processes that you're trying to notify of the chang

Re: [GENERAL] Trigger that spawns forked process

2005-05-10 Thread Christopher Murtagh
On Tue, 2005-05-10 at 11:11 -0500, Jim C. Nasby wrote: > Well, LISTEN and NOTIFY are built into PostgreSQL > (http://www.postgresql.org/docs/8.0/interactive/sql-notify.html). If the > processes that you're trying to notify of the changes are connected to > the database then this might be the easies

Re: [GENERAL] Trigger that spawns forked process

2005-05-10 Thread Jim C. Nasby
On Mon, May 09, 2005 at 09:07:40PM -0400, Christopher Murtagh wrote: > On Mon, 2005-05-09 at 17:01 -0400, Douglas McNaught wrote: > > Why not have a client connection LISTENing and doing the > > synchronization, and have the trigger use NOTIFY? > > > > Or, you could have the trigger write to a tab

Re: [GENERAL] Trigger that spawns forked process

2005-05-09 Thread Tom Lane
Christopher Murtagh <[EMAIL PROTECTED]> writes: > On Mon, 2005-05-09 at 17:07 -0400, Tom Lane wrote: >> ... not to mention it would avoid the risk of propagating >> not-yet-committed changes. > How's that? If I can notify a daemon that the change is committed, then > why couldn't I write a forkin

Re: [GENERAL] Trigger that spawns forked process

2005-05-09 Thread Douglas McNaught
Christopher Murtagh <[EMAIL PROTECTED]> writes: > On Mon, 2005-05-09 at 17:01 -0400, Douglas McNaught wrote: >> Why not have a client connection LISTENing and doing the >> synchronization, and have the trigger use NOTIFY? >> >> Or, you could have the trigger write to a table, and have another >>

Re: [GENERAL] Trigger that spawns forked process

2005-05-09 Thread Christopher Murtagh
On Mon, 2005-05-09 at 17:07 -0400, Tom Lane wrote: > Douglas McNaught <[EMAIL PROTECTED]> writes: > > Why not have a client connection LISTENing and doing the > > synchronization, and have the trigger use NOTIFY? > > Or, you could have the trigger write to a table, and have another > > client perio

Re: [GENERAL] Trigger that spawns forked process

2005-05-09 Thread Christopher Murtagh
On Mon, 2005-05-09 at 17:01 -0400, Douglas McNaught wrote: > Why not have a client connection LISTENing and doing the > synchronization, and have the trigger use NOTIFY? > > Or, you could have the trigger write to a table, and have another > client periodically scanning the table for new sync even

Re: [GENERAL] Trigger that spawns forked process

2005-05-09 Thread Tom Lane
Douglas McNaught <[EMAIL PROTECTED]> writes: > Why not have a client connection LISTENing and doing the > synchronization, and have the trigger use NOTIFY? > Or, you could have the trigger write to a table, and have another > client periodically scanning the table for new sync events. > Either one

Re: [GENERAL] Trigger that spawns forked process

2005-05-09 Thread Douglas McNaught
Christopher Murtagh <[EMAIL PROTECTED]> writes: > No, I don't want the trigger to do any db stuff at all. Basically, I've > got a content management system that is going to be split across a > cluster. Upon an update submission from one of them, I want to replicate > across the others (which can

Re: [GENERAL] Trigger that spawns forked process

2005-05-09 Thread Christopher Murtagh
On Mon, 2005-05-09 at 15:38 -0400, Tom Lane wrote: > Christopher Murtagh <[EMAIL PROTECTED]> writes: > > I would like to write a trigger or function that spawns a forked > > process so that the transaction is considered 'complete' to the client, > > but continues to perform more work. > > It's no

Re: [GENERAL] Trigger that spawns forked process

2005-05-09 Thread Tom Lane
Christopher Murtagh <[EMAIL PROTECTED]> writes: > I would like to write a trigger or function that spawns a forked > process so that the transaction is considered 'complete' to the client, > but continues to perform more work. It's not very clear what you are hoping to have the forked process do,

[GENERAL] Trigger that spawns forked process

2005-05-09 Thread Christopher Murtagh
I would like to write a trigger or function that spawns a forked process so that the transaction is considered 'complete' to the client, but continues to perform more work. I've been looking for examples to steal^H^H^H^H^H learn from but have only found someone asking pretty much the same question