Re: C function - other process

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Jakub Wo?ny <kubaw(at)o2(dot)pl>, pgsql-sql(at)postgresql(dot)org
Subject: Re: C function - other process
Date: 2005-04-22 20:07:48
Message-ID: 12489.1114200468@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Michael Fuhr <mike(at)fuhr(dot)org> writes:
> What about fork() followed by exec*(), either explicitly or via
> popen(), system(), etc.? Should these be avoided as well, or is
> there a safe way to do them? I'm thinking of the case where a
> user-defined function wants to invoke some external command -- I've
> done that in experiments but I've never been sure how safe it was.

Execing some new program is safe enough, although you might wish to
explicitly close the various sockets the backend holds to make sure
the new program doesn't maliciously scribble on them. (It may be worth
marking them close-on-exec, although doing this without breaking the
Windows port might be hard.)

The problem with the hack at hand is that you can't have two processes
sharing the same backend slot (not to mention the same transaction ID).
But launching something that isn't a backend is no problem.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2005-04-22 20:36:30 Re: C function - other process
Previous Message Michael Fuhr 2005-04-22 20:01:50 Re: C function - other process