2015-10-03 01:43:18 +02:00
|
|
|
/****************************************************************************
|
2023-01-23 23:52:51 +01:00
|
|
|
* libs/libc/pthread/pthread_kill.c
|
2007-03-24 00:22:22 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2007-03-24 00:22:22 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-03-24 00:22:22 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2007-03-24 00:22:22 +01:00
|
|
|
*
|
2015-10-03 01:43:18 +02:00
|
|
|
****************************************************************************/
|
2007-03-24 00:22:22 +01:00
|
|
|
|
2015-10-03 01:43:18 +02:00
|
|
|
/****************************************************************************
|
2007-03-24 00:22:22 +01:00
|
|
|
* Included Files
|
2015-10-03 01:43:18 +02:00
|
|
|
****************************************************************************/
|
2007-03-24 00:22:22 +01:00
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <errno.h>
|
2015-05-13 22:43:43 +02:00
|
|
|
|
2015-10-03 01:43:18 +02:00
|
|
|
/****************************************************************************
|
2015-05-13 22:43:43 +02:00
|
|
|
* Public Functions
|
2015-10-03 01:43:18 +02:00
|
|
|
****************************************************************************/
|
2007-03-24 00:22:22 +01:00
|
|
|
|
2015-10-03 01:43:18 +02:00
|
|
|
/****************************************************************************
|
2012-07-14 21:30:31 +02:00
|
|
|
* Name: pthread_kill
|
2007-03-24 00:22:22 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2012-07-14 21:30:31 +02:00
|
|
|
* The pthread_kill() system call can be used to send any signal to a
|
2017-10-07 16:22:18 +02:00
|
|
|
* thread. See nxsig_kill() for further information as this is just a
|
|
|
|
* simple wrapper around the nxsig_kill() function.
|
2007-03-24 00:22:22 +01:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2012-07-14 21:30:31 +02:00
|
|
|
* thread - The id of the thread to receive the signal. Only positive,
|
|
|
|
* non-zero values of 'thread' are supported.
|
|
|
|
* signo - The signal number to send. If 'signo' is zero, no signal is
|
|
|
|
* sent, but all error checking is performed.
|
2007-03-24 00:22:22 +01:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2012-07-14 21:30:31 +02:00
|
|
|
* On success the signal was send and zero is returned. On error one
|
|
|
|
* of the following error numbers is returned.
|
2007-03-24 00:22:22 +01:00
|
|
|
*
|
|
|
|
* EINVAL An invalid signal was specified.
|
|
|
|
* EPERM The thread does not have permission to send the
|
|
|
|
* signal to the target thread.
|
|
|
|
* ESRCH No thread could be found corresponding to that
|
|
|
|
* specified by the given thread ID
|
|
|
|
* ENOSYS Do not support sending signals to process groups.
|
|
|
|
*
|
2015-10-03 01:43:18 +02:00
|
|
|
****************************************************************************/
|
2007-03-24 00:22:22 +01:00
|
|
|
|
|
|
|
int pthread_kill(pthread_t thread, int signo)
|
|
|
|
{
|
2023-01-23 23:52:51 +01:00
|
|
|
int ret = tkill((pid_t)thread, signo);
|
2015-05-13 22:43:43 +02:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2023-01-23 23:52:51 +01:00
|
|
|
ret = get_errno();
|
2015-05-13 22:43:43 +02:00
|
|
|
}
|
2007-03-24 00:22:22 +01:00
|
|
|
|
2023-01-23 23:52:51 +01:00
|
|
|
return ret;
|
2015-05-13 22:43:43 +02:00
|
|
|
}
|