[BusyBox] [PATCH] Fix lash redirect squirrel with 'exec'

Joe.C joe at numa.com.tw
Thu Aug 5 21:12:31 MDT 2004


  When using lash exec builtin with redirection, the opened file
keep increasing. For example, please try the following command
with lash.


ls -al /proc/<lash pid>/fd
exec /bin/sh 2>/dev/null
ls -al /proc/<lash pid>/fd


  This one-line patch fix this problem by setting CLOEXEC flag for
squirrel fd. Please apply.

Joe.C

-------------- next part --------------
*** shell/lash.c.org	Fri Aug  6 11:01:16 2004
--- shell/lash.c	Fri Aug  6 11:01:39 2004
***************
*** 656,661 ****
--- 656,662 ----
  		if (openfd != redir->fd) {
  			if (squirrel && redir->fd < 3) {
  				squirrel[redir->fd] = dup(redir->fd);
+ 				fcntl (squirrel[redir->fd], F_SETFD, FD_CLOEXEC);
  			}
  			dup2(openfd, redir->fd);
  			close(openfd);


More information about the busybox mailing list