[comp.bugs.4bsd] rshd leaves too many files open

sjoerd@cwi.nl (Sjoerd Mullender) (01/18/89)

Index: etc/rshd.c 4.3BSD-tahoe Fix

Description:
	When you rsh to a remote machine, rsh leaves open a file
	descriptor other than 0, 1, and 2.
Repeat-By:
	Write a program that lists its open files and execute it
	using rsh.  Notice that there are 4 open files: 0, 1, 2, and
	one extra.
Fix:
	Add an extra close statement, as in the attached context diff.

*** /tmp/d16692	Mon Jan 16 14:50:45 1989
--- rshd.c	Mon Jan 16 14:25:58 1989
***************
*** 263,268 ****
--- 263,269 ----
  		setpgrp(0, getpid());
  		(void) close(s); (void) close(pv[0]);
  		dup2(pv[1], 2);
+ 		(void) close(pv[1]);
  	}
  	if (*pwd->pw_shell == '\0')
  		pwd->pw_shell = "/bin/sh";
-- 
Sjoerd Mullender		e-mail: sjoerd@cwi.nl
Centre for Mathematics and Computer Science, Amsterdam