$NetBSD: patch-ai,v 1.1 2006/12/19 07:53:57 wiz Exp $

plugged fd leaks.

http://mlterm.cvs.sourceforge.net/mlterm/mlterm/kiklib/src/kik_file.c?r1=1.5&r2=1.6&view=patch

--- kiklib/src/kik_file.c.orig	2003-01-12 12:34:31.000000000 +0000
+++ kiklib/src/kik_file.c
@@ -3,4 +3,5 @@
  */
 
+#include  <fcntl.h>		/* fcntl() */
 #include  "kik_file.h"
 
@@ -201,2 +202,42 @@ kik_file_unlock(
 
 #endif
+
+int
+kik_file_set_cloexec(
+	int fd
+	)
+{
+	int  old_flags ;
+	
+	old_flags = fcntl( fd, F_GETFD) ;
+	if( old_flags == -1)
+	{
+		return  0 ;
+	}
+	
+	if( !(old_flags & FD_CLOEXEC)
+	 && (fcntl( fd, F_SETFD, old_flags|FD_CLOEXEC) == -1) )
+	{
+		return  0 ;
+	}
+	return  1 ;
+}
+
+kik_file_unset_cloexec(
+	int fd
+	)
+{
+  	int  old_flags ;
+
+	old_flags = fcntl( fd, F_GETFD) ;
+        if( old_flags == -1)
+        {
+		return  0 ;
+	}
+	if( (old_flags & FD_CLOEXEC)
+	 && (fcntl( fd, F_SETFD, old_flags & (~FD_CLOEXEC)) == -1) )
+        {
+		return  0 ;
+	}
+	return  1 ;
+}
