Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[comment][libc] add some comments for functions in posix_signal #7647

Merged
merged 2 commits into from
Jun 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 43 additions & 6 deletions components/libc/posix/signal/posix_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ void (*signal(int sig, void (*func)(int))) (int)
*
* @return Returns 0 on success.
*/

int sigprocmask (int how, const sigset_t *set, sigset_t *oset)
{
rt_base_t level;
Expand Down Expand Up @@ -90,7 +89,16 @@ int sigpending (sigset_t *set)
sigprocmask(SIG_SETMASK, RT_NULL, set);
return 0;
}

/**
* @brief This function will temporarily replace the signal mask of the calling thread
* with the mask given and then suspends the thread until delivery of an expected signal
* or a signal whose action is to terminate a process.
*
* @param set is a pointer of a sigset_t object that is used to replace the original mask of the calling thread.
*
* @return Returns 0 on success.
* If the return value is any other values, it means that the signal wait failed.
*/
int sigsuspend (const sigset_t *set)
{
int ret = 0;
Expand Down Expand Up @@ -125,7 +133,6 @@ int sigsuspend (const sigset_t *set)
*
* @return Returns 0 on success or -1 on failure.
*/

int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
{
rt_sighandler_t old = RT_NULL;
Expand All @@ -145,7 +152,19 @@ int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)

return 0;
}

/**
* @brief This function will suspends execution of the calling thread until one of
* the signals in the given set is pending. If none of the signals specified
* are pending, it will wait for the specified time interval.
*
* @param set is the set of signal values to be waited for.
*
* @param info is a pointer to the received signal info.
*
* @param timeout is a pointer to a timespec structure that specifys the waiting time.
*
* @return Return 0 on success. Otherwise, return -1 and set errno to indicate the error.
*/
int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *timeout)
{
int ret = 0;
Expand All @@ -162,7 +181,16 @@ int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *ti
errno = ret;
return -1;
}

/**
* @brief This function will suspend execution of the calling thread until one of
* the specified signal becomes pending and return the signal number.
*
* @param set is the set of signal values to be waited for.
*
* @param sig is a pointer to the received signal number.
*
* @return Return 0 on success or -1 on failure.
*/
int sigwait(const sigset_t *set, int *sig)
{
siginfo_t si;
Expand All @@ -172,7 +200,16 @@ int sigwait(const sigset_t *set, int *sig)
*sig = si.si_signo;
return 0;
}

/**
* @brief This function will suspend execution of the calling thread until one of
* the specified signal is pending.
*
* @param set is the set of signal values to be waited for.
*
* @param info is a pointer to the received signal info.
*
* @return Return 0 on success or -1 on failure.
*/
int sigwaitinfo(const sigset_t *set, siginfo_t *info)
{
return sigtimedwait(set, info, NULL);
Expand Down