$NetBSD: patch-al,v 1.1 2006/12/19 07:53:57 wiz Exp $ plugged fd leaks. http://mlterm.cvs.sourceforge.net/mlterm/mlterm/xwindow/x_xim.c?r1=1.9&r2=1.11&view=patch --- xwindow/x_xim.c.orig 2005/02/10 15:15:08 1.9 +++ xwindow/x_xim.c 2006/10/23 13:09:36 1.11 @@ -5,6 +5,8 @@ #include "x_xim.h" #include /* sprintf */ #include /* strcmp/memset */ +#include /* dup/close */ +#include /* kik_set_file_cloexec */ #include @@ -121,6 +123,7 @@ char * xmod ; char * cur_locale ; int result ; + int next_fd ; /* to deal with brain-dead XIM implemantations */ /* 4 is the length of "@im=" */ if( ( xmod = alloca( 4 + strlen( xim->name) + 1)) == NULL) @@ -154,6 +157,12 @@ result = 0 ; + next_fd = dup( 0) ; + if( next_fd != -1) + { + /* remember the lowest unused fd */ + close( next_fd) ; + } if( XSetLocaleModifiers(xmod) && ( xim->im = XOpenIM( display , NULL , NULL , NULL))) { if( ( xim->encoding = ml_get_char_encoding( kik_get_codeset())) == ML_UNKNOWN_ENCODING || @@ -172,7 +181,12 @@ result = 1 ; } } - + if( next_fd > 0) + { + /* if XOpenIM() internally opens a fd, + * we should close it on exec() */ + kik_file_set_cloexec( next_fd) ; + } if( cur_locale) { /* restoring */