[PATCH] Close file descriptors if forking returns an error.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Konrad Rzeszutek <konrad@xxxxxxxxxxxxxxxxxxxx>

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

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux