X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1AB5D53571 for ; Fri, 22 Apr 2005 17:07:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51828-08 for ; Fri, 22 Apr 2005 20:07:49 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6039553563 for ; Fri, 22 Apr 2005 17:07:49 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j3MK7mfx012490; Fri, 22 Apr 2005 16:07:48 -0400 (EDT) To: Michael Fuhr Cc: Jakub Wo?ny , pgsql-sql@postgresql.org Subject: Re: C function - other process In-reply-to: <20050422200150.GA93845@winnie.fuhr.org> References: <20050422211800.241cf201@localhost> <12255.1114198795@sss.pgh.pa.us> <20050422200150.GA93845@winnie.fuhr.org> Comments: In-reply-to Michael Fuhr message dated "Fri, 22 Apr 2005 14:01:50 -0600" Date: Fri, 22 Apr 2005 16:07:48 -0400 Message-ID: <12489.1114200468@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/332 X-Sequence-Number: 21225 Michael Fuhr 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