Kernel/LibC: Implement SYS_ISATTY and isatty()

This commit is contained in:
2024-06-03 03:36:25 +03:00
parent 6346d1b6c7
commit aec5a09caf
4 changed files with 17 additions and 0 deletions

View File

@@ -162,6 +162,8 @@ namespace Kernel
BAN::ErrorOr<long> sys_smo_delete(SharedMemoryObjectManager::Key);
BAN::ErrorOr<long> sys_smo_map(SharedMemoryObjectManager::Key);
BAN::ErrorOr<long> sys_isatty(int fildes);
BAN::ErrorOr<long> sys_tty_ctrl(int fildes, int command, int flags);
BAN::ErrorOr<long> sys_signal(int, void (*)(int));

View File

@@ -1433,6 +1433,15 @@ namespace Kernel
return m_mapped_regions.back()->vaddr();
}
BAN::ErrorOr<long> Process::sys_isatty(int fildes)
{
LockGuard _(m_process_lock);
auto inode = TRY(m_open_file_descriptors.inode_of(fildes));
if (!inode->is_tty())
return BAN::Error::from_errno(ENOTTY);
return 0;
}
BAN::ErrorOr<long> Process::sys_tty_ctrl(int fildes, int command, int flags)
{
LockGuard _(m_process_lock);