[comp.unix.ultrix] Ultrix /bin/sh -- fun for the whole family

cks@white.toronto.edu (Chris Siebenmann) (02/21/90)

 The summary says it all. As evidence, make a shell script that
produces some output, compile the program below, and execute it,
handing it the name of the shell script. On Ultrix 2.2 and 3.1, on
both RISC machines and Vaxen, the script will produce no output
whatsoever. Better yet, the shell's exit status claims success!  We
don't run YP locally; I'd be interested in knowing if this happens
under YP.

	/* Illustrate a problem with Ultrix 2.2/3.1 and /bin/sh. */

	main(argc, argv)
	int	argc;
	char	**argv;
	{
		int	i, fd;

		fd = open("/dev/null", 0);
		for (i = 3; i < 10; i++)
			(void) dup2(fd, i);
		execvp(argv[1], argv+1);
		perror(argv[1]);
		exit(1);
		/*NOTREACHED*/
	}

 This can bite in all sorts of ways, like rn not saving things, and
multiply-nested shell scripts not working, and all sorts of other fun
things.

 Does someone with more patience for using typewriters and large
multi-carbon forms want to submit an official SPR?

--
	"I shall clasp my hands together and bow to the corners of the world."
			Number Ten Ox, "Bridge of Birds"
cks@white.toronto.edu		   ...!{utgpu,utzoo,watmath}!utcsri!white!cks