xref: /minix3/minix/lib/libasyn/asyn_close.c (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc /*	asyn_close() - forcefully forget about a file descriptor
2*433d6423SLionel Sambuc  *							Author: Kees J. Bot
3*433d6423SLionel Sambuc  *								7 Jul 1997
4*433d6423SLionel Sambuc  */
5*433d6423SLionel Sambuc #include "asyn.h"
6*433d6423SLionel Sambuc 
asyn_close(asynchio_t * asyn,int fd)7*433d6423SLionel Sambuc int asyn_close(asynchio_t *asyn, int fd)
8*433d6423SLionel Sambuc /* Stop caring about any async operations on this file descriptor. */
9*433d6423SLionel Sambuc {
10*433d6423SLionel Sambuc 	asynfd_t *afd;
11*433d6423SLionel Sambuc 	int op;
12*433d6423SLionel Sambuc 
13*433d6423SLionel Sambuc 	if ((unsigned) fd >= FD_SETSIZE) { errno= EBADF; return -1; }
14*433d6423SLionel Sambuc 
15*433d6423SLionel Sambuc 	afd= &asyn->asyn_afd[fd];
16*433d6423SLionel Sambuc 
17*433d6423SLionel Sambuc 	for (op= 0; op < SEL_NR; op++) {
18*433d6423SLionel Sambuc 		afd->afd_state[op]= IDLE;
19*433d6423SLionel Sambuc 		FD_CLR(fd, &asyn->asyn_fdset[op]);
20*433d6423SLionel Sambuc 	}
21*433d6423SLionel Sambuc 	afd->afd_seen= 0;
22*433d6423SLionel Sambuc 	asyn->asyn_more++;
23*433d6423SLionel Sambuc 	return 0;
24*433d6423SLionel Sambuc }
25