From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Fuhr <mike@fuhr.org>
Cc: Jakub Wo?ny <kubaw@o2.pl>
Cc: pgsql-sql@postgresql.org
Subject: Re: C function - other process
Date: Fri, 22 Apr 2005 16:07:48 -0400
Message-ID: <12489.1114200468@sss.pgh.pa.us> (raw)
In-Reply-To: <20050422200150.GA93845@winnie.fuhr.org>
References: <20050422211800.241cf201@localhost>
<12255.1114198795@sss.pgh.pa.us>
<20050422200150.GA93845@winnie.fuhr.org>
Michael Fuhr <mike@fuhr.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, mike@fuhr.org, kubaw@o2.pl
Subject: Re: C function - other process
In-Reply-To: <12489.1114200468@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox