system/src/newlib/_syscalls.c
/* fd, is a user file descriptor. */
fd, is a user file descriptor.
fd is a user file descriptor .
int
_close (int fd)
{
  int res;
  struct fdent *pfd;
  pfd = findslot (fd);
  if (pfd == NULL)
    {
      errno = EBADF;
      return -1;
    }
  if ((fd == 1 || fd == 2) && (openfiles[1].handle == openfiles[2].handle))
    {
      pfd->handle = -1;
      return 0;
    }
  res = _swiclose (pfd->handle);
  if (res == 0)
    {
      pfd->handle = -1;
    }
  return res;
}
int _close ( int fd ) { int res ; struct fdent * pfd ; pfd = findslot ( fd ) ; if ( pfd == NULL ) { errno = EBADF ; return -1 ; } if ( ( fd == 1 || fd == 2 ) && ( openfiles [ 1 ] . handle == openfiles [ 2 ] . handle ) ) { pfd -> handle = -1 ; return 0 ; } res = _swiclose ( pfd -> handle ) ; if ( res == 0 ) { pfd -> handle = -1 ; } return res ; }
fd, is a user file descriptor.
fd is a user file descriptor .
/* Handle stderr == stdout. */ /* Attempt to close the handle. */ /* Reclaim handle? */