reactos/posix/lib/psxdll/unistd/close.c
2002-10-29 04:45:58 +00:00

42 lines
824 B
C

/* $Id: close.c,v 1.4 2002/10/29 04:45:46 rex Exp $
*/
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS POSIX+ Subsystem
* FILE: subsys/psx/lib/psxdll/unistd/close.c
* PURPOSE: Close a file descriptor
* PROGRAMMER: KJK::Hyperion <noog@libero.it>
* UPDATE HISTORY:
* 13/02/2002: Created
*/
#include <ddk/ntddk.h>
#include <unistd.h>
#include <fcntl.h>
#include <psx/errno.h>
#include <psx/stdlib.h>
#include <psx/fdtable.h>
int close(int fildes)
{
__fildes_t fdDescriptor;
NTSTATUS nErrCode;
if(fcntl(fildes, F_DELFD, &fdDescriptor) == -1)
return (-1);
__free(fdDescriptor.ExtraData);
nErrCode = NtClose(fdDescriptor.FileHandle);
if(!NT_SUCCESS(nErrCode))
{
errno = __status_to_errno(nErrCode);
return (-1);
}
return (0);
}
/* EOF */