[lockdev-devel] [PATCH 4/4] make sure fds 0-2 are open in the helper binary

Ludwig Nussel ludwig.nussel at suse.de
Tue Mar 2 09:22:25 UTC 2010


---
 src/sample.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/sample.c b/src/sample.c
index b2dd095..a2c1f45 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -17,8 +17,16 @@ main (int   argc,
       char *argv[])
 {
 	int i;
+	int fd;
 	char *p = NULL, *dev = NULL, ch;
 
+        /* these have to be open to something */
+	if ((fd = open("/dev/null", 2)) < 0)
+	    exit(-1);
+	dup2(fd, 0);
+	dup2(fd, 1);
+	dup2(fd, 2);
+
 	ch = '\0';
 	for( i = argc - 1; i > 0; i-- ) {
 		p = argv[i];
-- 
1.6.4.2




More information about the lockdev-devel mailing list