busybox 'script' applet

Pascal Bellard pascal.bellard at ads-lu.com
Mon Nov 26 18:14:41 UTC 2007


Hello,

Please find attached a patch to add 'script' applet

Hope it helps,

-pascal

BTW, an xclose could save 10-12 'if (fd >= 0) close(fd);', see attached
file xclose.log

> Author: vda
> Date: 2007-11-25 21:37:07 -0800 (Sun, 25 Nov 2007)
> New Revision: 20535
>
> Log:
> ash: make code simpler, and do not do close(-1) - it's rude
>
>
>
> Modified:
>    trunk/busybox/shell/ash.c
>
>
> Changeset:
> Modified: trunk/busybox/shell/ash.c
> ===================================================================
> --- trunk/busybox/shell/ash.c	2007-11-25 23:30:29 UTC (rev 20534)
> +++ trunk/busybox/shell/ash.c	2007-11-26 05:37:07 UTC (rev 20535)
> @@ -3461,14 +3461,17 @@
>  	 * That sometimes helps to acquire controlling tty.
>  	 * Obviously, a workaround for bugs when someone
>  	 * failed to provide a controlling tty to bash! :) */
> -			fd += 3;
> -			while (!isatty(fd) && --fd >= 0)
> -				;
> +			fd = 2;
> +			while (!isatty(fd))
> +				if (--fd < 0)
> +					goto out;
>  		}
>  		fd = fcntl(fd, F_DUPFD, 10);
> -		close(ofd);
> +		if (ofd >= 0)
> +			close(ofd);
>  		if (fd < 0)
>  			goto out;
> +		/* fd is a tty at this point */
>  		close_on_exec_on(fd);
>  		do { /* while we are in the background */
>  			pgrp = tcgetpgrp(fd);
> @@ -3502,7 +3505,8 @@
>  		setsignal(SIGTTOU);
>  		setsignal(SIGTTIN);
>   close:
> -		close(fd);
> +		if (fd >= 0)
> +			close(fd);
>  		fd = -1;
>  	}
>  	ttyfd = fd;
>
> _______________________________________________
> busybox-cvs mailing list
> busybox-cvs at busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: busybox-1.8.2-APPLET-SCRIPT.u
Type: application/octet-stream
Size: 7831 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox-cvs/attachments/20071126/fa0e0186/attachment-0004.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xclose.log
Type: application/octet-stream
Size: 903 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox-cvs/attachments/20071126/fa0e0186/attachment-0005.obj 


More information about the busybox-cvs mailing list