blob: d021bb6cbec253c29afba65cb96639eecc82e417 [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 TTY_FD_INVALID:
//errno = EBADF;
return -1;
case TTY_FD_DEFAULT:
return _set_stdout_fd(TTY_FD_INVALID);
default:
fd = real_fd;
}
} else if(fd == STDERR_FILENO) {
int real_fd = _get_stderr_fd();
switch(real_fd) {
case TTY_FD_INVALID:
//errno = EBADF;
return -1;
case TTY_FD_DEFAULT:
return _set_stderr_fd(TTY_FD_INVALID);
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
}