From patchwork Thu Jan 8 19:25:04 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek X-Patchwork-Id: 1408 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n08JUoxW021928 for ; Thu, 8 Jan 2009 11:30:50 -0800 Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 22E58619F67; Thu, 8 Jan 2009 14:34:29 -0500 (EST) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n08JYQAL017341 for ; Thu, 8 Jan 2009 14:34:26 -0500 Received: from mx1.redhat.com (mx1.redhat.com [172.16.48.31]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n08JYR2l011298 for ; Thu, 8 Jan 2009 14:34:27 -0500 Received: from mars.virtualiron.com (host-216-57-134-2.customer.veroxity.net [216.57.134.2]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n08JYDbT018928 for ; Thu, 8 Jan 2009 14:34:13 -0500 Received: by mars.virtualiron.com (Postfix, from userid 1179) id B3C0C17E8D; Thu, 8 Jan 2009 14:25:04 -0500 (EST) From: Konrad Rzeszutek To: dm-devel@redhat.com Date: Thu, 8 Jan 2009 14:25:04 -0500 Message-Id: <1231442704-19032-2-git-send-email-konrad@virtualiron.com> In-Reply-To: <1231442704-19032-1-git-send-email-konrad@virtualiron.com> References: <1231442704-19032-1-git-send-email-konrad@virtualiron.com> X-RedHat-Spam-Score: -0.102 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.31 X-loop: dm-devel@redhat.com Cc: Subject: [dm-devel] [PATCH] Close file descriptors if forking returns an error. X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com From: Konrad Rzeszutek And also use vfork instead of fork so that the heap space count of the parent process (multipathd) will not be counted against the program which will executed (scsi_id or other). --- libmultipath/callout.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/libmultipath/callout.c b/libmultipath/callout.c index 4dd33c5..6f9d195 100644 --- a/libmultipath/callout.c +++ b/libmultipath/callout.c @@ -68,7 +68,7 @@ int execute_program(char *path, char *value, int len) return -1; - pid = fork(); + pid = vfork(); switch(pid) { case 0: @@ -91,6 +91,9 @@ int execute_program(char *path, char *value, int len) exit(-1); case -1: + close(fds[0]); + close(fds[1]); + condlog(0, "error forking: %s. errno:%d\n", path, errno); return -1; default: /* parent reads from fds[0] */