Kernel/LibC: Implement pthread_kill
This commit is contained in:
@@ -194,6 +194,7 @@ namespace Kernel
|
||||
BAN::ErrorOr<long> sys_pthread_exit(void* value);
|
||||
BAN::ErrorOr<long> sys_pthread_join(pthread_t thread, void** value);
|
||||
BAN::ErrorOr<long> sys_pthread_self();
|
||||
BAN::ErrorOr<long> sys_pthread_kill(pthread_t thread, int signal);
|
||||
|
||||
BAN::ErrorOr<long> sys_tcgetpgrp(int fd);
|
||||
BAN::ErrorOr<long> sys_tcsetpgrp(int fd, pid_t pgid);
|
||||
|
||||
@@ -2557,6 +2557,25 @@ namespace Kernel
|
||||
return Thread::current().tid();
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> Process::sys_pthread_kill(pthread_t tid, int signal)
|
||||
{
|
||||
if (signal != 0 && (signal < _SIGMIN || signal > _SIGMAX))
|
||||
return BAN::Error::from_errno(EINVAL);
|
||||
|
||||
LockGuard _(m_process_lock);
|
||||
|
||||
for (auto* thread : m_threads)
|
||||
{
|
||||
if (thread->tid() != tid)
|
||||
continue;
|
||||
if (signal != 0)
|
||||
thread->add_signal(signal);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return BAN::Error::from_errno(ESRCH);
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> Process::sys_tcgetpgrp(int fd)
|
||||
{
|
||||
LockGuard _(m_process_lock);
|
||||
|
||||
Reference in New Issue
Block a user