[4259] in Athena Bugs
tcsh: doesn't clean up file descriptors
daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Mon Feb 19 09:14:05 1990
Date: Mon, 19 Feb 90 09:13:49 -0500
From: Jonathan I. Kamens <jik@PIT-MANAGER.MIT.EDU>
To: bugs@ATHENA.MIT.EDU
The following program:
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
main()
{
int i, max;
struct stat buf;
max = getdtablesize();
for (i = 0; i < max; i++) {
if (! fstat(i, &buf))
printf("File descriptor %d is open.\n", i);
else if (errno != EBADF)
perror("fstat");
}
exit(0);
}
Produces the following output when run from tcsh:
pit-manager% /tmp/foo
File descriptor 0 is open.
File descriptor 1 is open.
File descriptor 2 is open.
File descriptor 16 is open.
File descriptor 17 is open.
File descriptor 18 is open.
File descriptor 19 is open.
The problem is that the file descriptors 16, 17, 18 and 19 should
NOT be open when /tmp/foo is executing -- tcsh should clean them up
after doing the fork(), before exec()ing /tmp/foo.
This is, I think, a bug on all architectures.
jik