[dm-devel] [PATCH] Close file descriptors if forking returns an error.
Konrad Rzeszutek
konrad at virtualiron.com
Thu Jan 8 19:25:04 UTC 2009
From: Konrad Rzeszutek <konrad at 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 --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
More information about the dm-devel
mailing list