blob: 42ddd13c31f1c989868a332637a11870a01d32b3 [file] [log] [blame] [raw]
#include <windows.h>
#include <nt.h>
//#include <errno.h>
#include <unistd.h>
int close(int fd) {
if(fd == STDOUT_FILENO) {
int real_fd = _get_stdout_fd();
switch(real_fd) {
case -2:
//errno = EBADF;
return -1;
case -1:
return _set_stdout_fd(-2);
default:
fd = real_fd;
}
} else if(fd == STDERR_FILENO) {
int real_fd = _get_stderr_fd();
switch(real_fd) {
case -2:
//errno = EBADF;
return -1;
case -1:
return _set_stderr_fd(-2);
default:
fd = real_fd;
}
}
long int status = NtClose((void *)fd);
//return ntstatus_to_errno(status) ? -1 : 0;
return status ? -1 : 0; // TODO: implemente the errno
}