diff mbox

Close file descriptors if forking returns an error.

Message ID 1231442704-19032-2-git-send-email-konrad@virtualiron.com (mailing list archive)
State Superseded, archived
Delegated to: christophe varoqui
Headers show

Commit Message

Konrad Rzeszutek Jan. 8, 2009, 7:25 p.m. UTC
From: Konrad Rzeszutek <konrad@mars.virtualiron.com>

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 mbox

Patch

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] */