Aunc.1057
net.4bsd-bugs,net.v7-bugs
utzoo!decvax!duke!unc!smb
Thu Aug 20 22:04:12 1981
missing file descriptors
If a process is interrupted while trying to open a file, the
file descriptor tentatively assigned is lost -- unless you
know what it should be and close it! The following program
demonstrates this. (This was run under 4bsd, but I believe
the same problem is present in V6 and V7.) Note that this
implies that a device driver close routine can be called
for a file that was never successfully opened -- which might
cause problems for weird devices/drivers.
#include <SIGNAL.H>
#include <ERRNO.H>
#define CLOSEDTTY "/dev/ttyia" /* should wait forever */
#define FLIM 25 /* maximum open files */
extern errno;
main()
{
int i, j;
int f;
int tick();
char lbuf[100];
signal(SIGALRM, tick);
for (j = 0; j<2; < F="open(CLOSEDTTY," FOR I++) I { J++) FLIM; ALARM(2); (F (I="0;" I<FLIM; IF CLOSE(I); 1);>= 0) {
printf("Huh -- f=%d\n", f);
}
else if (errno != EINTR) {
alarm(0);
sprintf(lbuf, "i=%d j=%d", i, j);
perror(lbuf);
break;
}
if (j) {
if (close(3)
<HR>
This Usenet Oldnews Archive
article may be copied and distributed freely, provided:
<P>
1. There is no money collected for the text(s) of the articles.
<BR>
2. The following notice remains appended to each copy:
<P>
<EM>The Usenet Oldnews Archive: Compilation Copyright© 1981, 1996
<BR> Bruce Jones, Henry Spencer, David Wiseman.</EM>
<P>
<HR>
Goto <A HREF="81.11.11_ucf.212_net.4bsd-bugs.html">NEXT</A> article in NET.bugs.4bsd Newsgroup
<BR>Return to <A HREF="NET.bugs.4bsd-index.html">NET.bugs.4bsd index</A>
<BR>Return to the
<A HREF="../index.html">Usenet Oldnews Archive index</A>
</HTML>
-----------------------------------------------------------------
gopher://quux.org/ conversion by John Goerzen <
[email protected]>
of
http://communication.ucsd.edu/A-News/
This Usenet Oldnews Archive
article may be copied and distributed freely, provided:
1. There is no money collected for the text(s) of the articles.
2. The following notice remains appended to each copy:
The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996
Bruce Jones, Henry Spencer, David Wiseman.