- IPC
- Overview
- Summary
- Files
- Data Structures
- Macros
- Typedefs
- Functions
- Details
- Macro Definition Documentation
- MINSIGSTKSZ [1/2]
- MINSIGSTKSZ [2/2]
- sa_handler [1/2]
- sa_handler [2/2]
- SA_NOCLDSTOP [1/2]
- SA_NOCLDSTOP [2/2]
- SA_NODEFER [1/2]
- SA_NODEFER [2/2]
- SA_ONSTACK [1/2]
- SA_ONSTACK [2/2]
- sa_sigaction [1/2]
- sa_sigaction [2/2]
- SA_SIGINFO [1/2]
- SA_SIGINFO [2/2]
- SIGRTMAX [1/2]
- SIGRTMAX [2/2]
- SIGRTMIN [1/2]
- SIGRTMIN [2/2]
- SIGSTKSZ [1/2]
- SIGSTKSZ [2/2]
- Typedef Documentation
- stack_t
- Function Documentation
- kill()
- mq_close()
- mq_getattr()
- mq_open()
- mq_receive()
- mq_send()
- mq_setattr()
- mq_timedreceive()
- mq_timedsend()
- mq_unlink()
- psignal()
- pthread_sigmask()
- raise()
- sem_close()
- sem_destroy()
- sem_getvalue()
- sem_init()
- sem_post()
- sem_timedwait()
- sem_trywait()
- sem_unlink()
- sem_wait()
- sigaction()
- sigaddset()
- sigandset()
- sigdelset()
- sigemptyset()
- sigfillset()
- sighold()
- sigisemptyset()
- sigismember()
- signal()
- sigorset()
- sigpause()
- sigpending()
- sigprocmask()
- sigrelse()
- sigsuspend()
- sigtimedwait()
- sigwait()
- sigwaitinfo()
IPC
Overview
Provides functions and structures related to inter-process communication (IPC), including signals, semaphores, and message queues.
Since:
1.0
Version:
1.0
Summary
Files
Data Structures
Defines the signal processing actions and related attributes. You can use the structures to change the processing actions or attributes. |
|
Macros
Defines the input parameter used to obtain information from the kernel. |
|
SEM_FAILED ((sem_t )0) |
|
Stops a child process without sending the SIGCHLD signal. |
|
SA_NOCLDSTOP 0x00000001 |
Stops a child process without sending the SIGCHLD signal. |
Sets the SIGCHLD flag to prevent zombie processes. |
|
Sets the SIGCHLD flag to prevent zombie processes. |
|
SA_SIGINFO 0x00000004 |
|
SA_ONSTACK 0x08000000 |
Uses the signal stack specified by sigaltstack for signal processing. |
SA_ONSTACK 0x08000000 |
Uses the signal stack specified by sigaltstack for signal processing. |
SA_NODEFER 0x40000000 |
The signals being processed are not masked during signal processing. |
SA_NODEFER 0x40000000 |
The signals being processed are not masked during signal processing. |
The default processing mode is restored after the signal processing is complete. |
|
The default processing mode is restored after the signal processing is complete. |
|
Not intended for application use. This flag is used by C libraries to indicate that the sa_restorer field contains the address of a trampoline. |
|
Not intended for application use. This flag is used by C libraries to indicate that the sa_restorer field contains the address of a trampoline. |
|
MINSIGSTKSZ 2048 |
|
MINSIGSTKSZ 2048 |
|
SIGSTKSZ 8192 |
|
SIGSTKSZ 8192 |
|
_NSIG_BPW BITS_PER_LONG |
|
Equivalent to SIGABRT. |
|
Virtual timer, used to calculate the CPU occupation time of a process. |
|
Calculates the CPU time occupied by a process and the system calling time. |
|
SIGPOLL SIGIO |
Equivalent to SIGIO. |
Equivalent to SIGSYS. |
|
SIGRTMIN 32 |
|
SIGRTMIN (libc_current_sigrtmin()) |
|
SIGRTMAX (libc_current_sigrtmax()) |
|
Transfers signals in a 32-bit mode even if the task runs in a 26-bit mode. |
|
SA_NOMASK SA_NODEFER |
Signals being processed are not masked during signal processing. |
SA_ONESHOT SA_RESETHAND |
The default processing mode is restored after the signal processing is complete. |
Defines the function behaviors such as sigprocmask() and pthread_sigmask(), which are used to add signals to the mask set. |
|
Defines the function behaviors such as sigprocmask() and pthread_sigmask(), which are used to remove signals from the mask set. |
|
Defines the function behaviors such as sigprocmask() and pthread_sigmask(), which are used to set the mask set. |
|
sa_handler _u._sa_handler |
Defines the simplified writing used to indicate the sa_handler.sa_handler field in sigaction. |
sa_handler sa_handler.sa_handler |
Defines the simplified writing used to indicate the sa_handler.sa_handler field in sigaction. |
sa_sigaction _u._sa_sigaction |
Defines the simplified writing used to indicate the sa_handler.sa_sigaction field in sigaction. |
sa_sigaction sa_handler.sa_sigaction |
Defines the simplified writing used to indicate the __sa_handler.sa_sigaction field in sigaction. |
Defines the function behaviors such as sigset() and adds a specified signal to the process signal mask without changing the current processing mode of the signal. |
|
Sets the notification method in sigevent: signal notification. |
|
Sets the notification method in sigevent: no notification. |
|
Sets the notification method in sigevent: thread notification. |
|
Defines the value returned when a function such as signal() fails. |
|
Defines the signal processing mode in which the signal is ignored. |
|
Defines the input parameter used together with IPC_CREAT to prevent duplicate key values during IPC creation. |
|
Defines the input parameter that specifies whether the communication is in non-blocking mode. |
|
Defines the input parameter used to set information to the kernel. |
|
Defines the input parameter used to obtain the system-level restriction information of a specified communication type, for example, shminfo. |
|
Typedefs
typedef struct __ucontext |
|
typedef struct sigaltstack |
|
Functions
mq_close (mqd_t mqdes) |
|
mq_getattr (mqd_t mqdes, struct mq_attr attr) |
Obtains the attributes of the message queue specified by the descriptor. The values of mq_maxmsg, mq_msgsize, and mq_curmsgs are fixed. |
mq_open (const char name, int oflag,…) |
|
mq_receive (mqd_t mqdes, char buffer, size_t size, unsigned prioptr) |
|
mq_send (mqd_t mqdes, const char buffer, size_t size, unsigned prio) |
|
mq_setattr (mqd_t mqdes, const struct mq_attr restrict newattr, struct mq_attr *restrict oldattr) |
Sets the attributes of the message queue specified by the descriptor. The mq_maxmsg, mq_msgsize, and mq_curmsgs attributes cannot be modified. mq_flags supports the O_NONBLOCK attribute only. |
mq_timedreceive (mqd_t mqdes, char __restrict buffer, size_t size, unsigned restrict prioptr, const struct timespec *restrict timeout) |
Receives a message from the message queue, with a timeout period specified. |
mq_timedsend (mqd_t mqdes, const char buffer, size_t size, unsigned prio, const struct timespec timeout) |
Sends a message to a specified message queue, with a timeout period specified. |
mq_unlink (const char name) |
Decreases the reference count of the message queue by 1, or deletes the message queue if the reference count is 0. |
sem_destroy (sem_t sem) |
Destroys a specified anonymous semaphore that is no longer used. |
sem_getvalue (sem_t restrict sem, int *restrict sval) |
|
sem_timedwait (sem_t __restrict sem, const struct timespec restrict timeout) |
|
sem_trywait (sem_t sem) |
|
sem_unlink (const char name) |
|
kill (pid_t pid, int sig) |
|
sigemptyset (sigset_t set) |
|
sigfillset (sigset_t set) |
|
sigaddset (sigset_t set, int signum) |
|
sigdelset (sigset_t set, int signum) |
|
sigismember (const sigset_t set, int signum) |
|
sigprocmask (int how, const sigset_t *restrict set, sigset_t __restrict oldset) |
|
sigsuspend (const sigset_t mask) |
Sets mask as the signal mask set of the current process and suspends the process until a signal processing action is triggered. |
sigaction (int signum, const struct sigaction __restrict act, struct sigaction restrict oldact) |
Checks or changes the processing action associated with a specified signal. Do not use the process creation function or thread creation function in the registered callback processing function. Otherwise, the process is abnormal. For example, do not use the fork or pthread_create function. |
sigpending (sigset_t set) |
|
sigwait (const sigset_t restrict set, int __restrict sig) |
|
sigwaitinfo (const sigset_t restrict set, siginfo_t *restrict info) |
Suspends the calling thread and waits for the signal, with a timeout period specified. |
sigtimedwait (const sigset_t __restrict set, siginfo_t restrict info, const struct timespec *restrict timeout) |
Suspends the calling thread and waits for the signal, with a timeout period specified. |
pthread_sigmask (int how, const sigset_t __restrict set, sigset_t __restrict oldset) |
|
psignal (int signum, const char s) |
|
sigpause (int signum) |
Deletes the signal specified by signum from the signal mask of the calling process and suspends the process until the signal is received. |
sighold (int signum) |
Adds the signal specified by signum to the signal mask of the calling process. |
sigrelse (int signum) |
Deletes the signal specified by signum from the signal mask of the calling process. |
sigisemptyset (const sigset_t set) |
|
sigorset (sigset_t dest, const sigset_t left, const sigset_t right) |
|
sigandset (sigset_t dest, const sigset_t left, const sigset_t right) |
|
signal (int signum, sighandler_t handler) |
Changes the processing action of a specified signal. Do not use the process creation function or thread creation function in the registered callback processing function. Otherwise, the process is abnormal. For example, do not use the fork or pthread_create function. |
raise (int signum) |
Details
Macro Definition Documentation
MINSIGSTKSZ [1/2]
#define MINSIGSTKSZ 2048
Description:
Defines the minimum size of the replaceable signal stack.
Minimum size of the replaceable signal stack.
MINSIGSTKSZ [2/2]
#define MINSIGSTKSZ 2048
Description:
Defines the minimum size of the replaceable signal stack.
Minimum size of the replaceable signal stack.
sa_handler [1/2]
#define sa_handler _u._sa_handler
Description:
Defines the simplified writing used to indicate the __sa_handler.sa_handler field in sigaction.
Indicates the _u._sa_handler field in sigaction.
sa_handler [2/2]
#define sa_handler __sa_handler.sa_handler
Description:
Defines the simplified writing used to indicate the __sa_handler.sa_handler field in sigaction.
Indicates the _u._sa_handler field in sigaction.
SA_NOCLDSTOP [1/2]
#define SA_NOCLDSTOP 1
Description:
Stops a child process without sending the SIGCHLD signal.
SIGCHLD is not generated when the child process is stopped.
SA_NOCLDSTOP [2/2]
#define SA_NOCLDSTOP 0x00000001
Description:
Stops a child process without sending the SIGCHLD signal.
SIGCHLD is not generated when the child process is stopped.
SA_NODEFER [1/2]
#define SA_NODEFER 0x40000000
Description:
The signals being processed are not masked during signal processing.
Signals being processed are not masked during signal processing.
SA_NODEFER [2/2]
#define SA_NODEFER 0x40000000
Description:
The signals being processed are not masked during signal processing.
Signals being processed are not masked during signal processing.
SA_ONSTACK [1/2]
#define SA_ONSTACK 0x08000000
Description:
Uses the signal stack specified by sigaltstack for signal processing.
The signal stack specified by sigaltstack is used for signal processing.
SA_ONSTACK [2/2]
#define SA_ONSTACK 0x08000000
Description:
Uses the signal stack specified by sigaltstack for signal processing.
The signal stack specified by sigaltstack is used for signal processing.
sa_sigaction [1/2]
#define sa_sigaction _u._sa_sigaction
Description:
Defines the simplified writing used to indicate the __sa_handler.sa_sigaction field in sigaction.
Indicates the __sa_handler.sa_sigaction field in sigaction.
sa_sigaction [2/2]
#define sa_sigaction __sa_handler.sa_sigaction
Description:
Defines the simplified writing used to indicate the __sa_handler.sa_sigaction field in sigaction.
Indicates the __sa_handler.sa_sigaction field in sigaction.
SA_SIGINFO [1/2]
#define SA_SIGINFO 4
Description:
Transfers the siginfo_t structure with the signal.
Transfers the siginfo_t with the signal.
SA_SIGINFO [2/2]
#define SA_SIGINFO 0x00000004
Description:
Transfers the siginfo_t structure with the signal.
Transfers the siginfo_t with the signal.
SIGRTMAX [1/2]
#define SIGRTMAX [_NSIG]($api-api-SmartVision-Devices-IPC.md#ga275020780cb70a8b0cba8db5accc5d19)
Description:
End of a reliable signal.
Defines the highest available signal number.
SIGRTMAX [2/2]
#define SIGRTMAX (__libc_current_sigrtmax())
Description:
End of a reliable signal.
Defines the highest available signal number.
SIGRTMIN [1/2]
#define SIGRTMIN 32
Description:
Start of a reliable signal.
Defines the lowest available signal number.
SIGRTMIN [2/2]
#define SIGRTMIN (__libc_current_sigrtmin())
Description:
Start of a reliable signal.
Defines the lowest available signal number.
SIGSTKSZ [1/2]
#define SIGSTKSZ 8192
Description:
Defines the size of a signal stack.
Size of a signal stack.
SIGSTKSZ [2/2]
#define SIGSTKSZ 8192
Description:
Defines the size of a signal stack.
Size of a signal stack.
Typedef Documentation
stack_t
typedef struct [sigaltstack]($api-api-SmartVision-Devices-sigaltstack.md) [stack_t]($api-api-SmartVision-Devices-IPC.md#ga395f9ff4025fe05bb535322593abde72)
Description:
Describes a signal stack.
Describes stack information for signal processing.
Function Documentation
kill()
int kill (pid_t pid, int sig )
Description:
Sends a signal to a specified process.
Parameters:
pid | Indicates the target process ID. Parameters 0 and -1 are not supported. |
sig | Indicates the signal to be sent. |
Attention:
The default signal behavior does not support STOP and CONTINUE, and COREDUMP is not involved. SIGSTOP, SIGKILL, and SIGCONT cannot be masked. If a process is killed but its parent process is not recycled, a zombie process will be generated. After an asynchronous signal is sent to a process, the signal callback is executed only after the process is scheduled. The kernel cannot forcibly kill the process by using the signal. After the process is killed, SIGCHLD is sent to its parent process. The sending action cannot be canceled. A sleeping process cannot be woken up by a signal. For example, a process invokes the sleep function to enter the sleeping state. Currently, suspended and zombie processes cannot be forcibly killed.
Returns:
Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.
The current process does not have permission to send the signal to the target process. |
mq_close()
int mq_close (mqd_t mqdes)
Description:
Closes a message queue that is no longer used.
Parameters:
mqdes | Indicates the descriptor of the message queue to be closed. |
Returns:
Returns 0 if the message queue is closed; returns -1 and sets errno to a value in the following table if the message queue fails to be closed.
Failed to release the space allocated with the message queue. |
|
mqdes is invalid when the message queue is deleted in the function. |
mq_getattr()
int mq_getattr (mqd_t mqdes, struct [mq_attr]($api-api-SmartVision-Devices-mq_attr.md) * attr )
Description:
Obtains the attributes of the message queue specified by the descriptor. The values of mq_maxmsg, mq_msgsize, and mq_curmsgs are fixed.
Parameters:
mqdes | Indicates the message queue descriptor. |
attr | Indicates the pointer to the obtained message queue attributes. |
Returns:
Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.
mq_open()
mqd_t mq_open (const char * name, int oflag, ... )
Description:
Creates a message queue or opens an existing message queue.
Parameters:
name | Indicates the name of the message queue to be created or opened. The maximum value is 259 bytes. |
oflag | Indicates the open flag, including O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, and O_NONBLOCK. |
mode | Used for permission control (not supported currently). Its type is mode_t. This is parameter is required only during the creation of a message queue. |
attr | Indicates the pointer to the queue attributes to be set. Its type is struct mq_attr. This parameter is optional and is used only during the creation of a message queue. |
Attention:
The message consists of 64 bytes by default, and the maximum length of the message is 64 KB. A maximum of 1024 message queues can be created. The mq_curmsgs field in mq_attr is not supported.
Returns:
Returns a message queue descriptor if the creation or opening is successful; returns (mqd_t)-1 and sets errno to a value in the following table if the operation fails.
Both O_CREAT and O_EXCL are specified in oflag, and a queue with this name already exists. |
|
O_CREAT is specified in oflag, and attr is invalid. To be specific, the attribute value of the mq_maxmsg field is less than 0 or greater than USHRT_MAX, or the attribute value of mq_msgsize is less than 0 or greater than USHRT_MAX-4. name is NULL, or the length of the string specified by name is 0. |
|
O_CREAT is not specified in oflag, and no queue with this name exists. |
|
mq_receive()
ssize_t mq_receive (mqd_t mqdes, char * buffer, size_t size, unsigned * prioptr )
Description:
Receives a message from a specified message queue.
The message queue must have been open by mq_open().
Parameters:
Returns:
Returns the number of bytes in the received message if the message is received; returns (mqd_t)-1 and sets errno to a value in the following table if the message fails to be received.
mq_send()
int mq_send (mqd_t mqdes, const char * buffer, size_t size, unsigned prio )
Description:
Sends a message to a specified message queue.
The message queue must have been opened using mq_open().
Parameters:
Returns:
Returns 0 if the message is sent; returns -1 and sets errno to a value in the following table if the message fails to be sent.
The message queue is full, and O_NONBLOCK is set for the message queue associated with mqdes. |
|
The size of the message to be sent is greater than the message size attribute of the message queue. |
|
mq_setattr()
int mq_setattr (mqd_t mqdes, const struct [mq_attr]($api-api-SmartVision-Devices-mq_attr.md) *__restrict newattr, struct [mq_attr]($api-api-SmartVision-Devices-mq_attr.md) *__restrict oldattr )
Description:
Sets the attributes of the message queue specified by the descriptor. The mq_maxmsg, mq_msgsize, and mq_curmsgs attributes cannot be modified. mq_flags supports the O_NONBLOCK attribute only.
The message queue must have been opened using mq_open().
Parameters:
mqdes | Indicates the message queue descriptor. |
newattr | Indicates the pointer to the message queue attribute to be set. |
oldattr | Indicates the pointer to the original attribute. |
Returns:
Returns 0 if the setting is successful; returns -1 and sets errno to a value in the following table if the setting fails.
mq_timedreceive()
ssize_t mq_timedreceive (mqd_t mqdes, char *__restrict buffer, size_t size, unsigned *__restrict prioptr, const struct [timespec]($api-api-SmartVision-Devices-timespec.md) *__restrict timeout )
Description:
Receives a message from the message queue, with a timeout period specified.
The message queue must have been open by mq_open().
Parameters:
Returns:
Returns the number of bytes in the message if the message is received; returns (mqd_t)-1 and sets errno to a value in the following table if the message fails to be received.
mq_timedsend()
int mq_timedsend (mqd_t mqdes, const char * buffer, size_t size, unsigned prio, const struct [timespec]($api-api-SmartVision-Devices-timespec.md) * timeout )
Description:
Sends a message to a specified message queue, with a timeout period specified.
The message queue must have been open by mq_open().
Parameters:
Returns:
Returns 0 if the message is sent; returns -1 and sets errno to a value in the following table if the message fails to be sent.
mq_unlink()
int mq_unlink (const char * name)
Description:
Decreases the reference count of the message queue by 1, or deletes the message queue if the reference count is 0.
Parameters:
name | Indicates the message queue name. |
Returns:
Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.
name is NULL, or the length of the string specified by name is 0. |
psignal()
void psignal (int signum, const char * s )
Description:
Prints signal information.
This function is used to print a message on the standard error output. The message consists of the character string s, a colon, a space, a string describing the signal information signum, and a newline character. If the string s is NULL or empty, the colon and space are omitted. If signum is invalid, the message displayed will indicate an unknown signal.
Parameters:
signum | Indicates the signal to be operated. |
s | Indicates the customized string s to be printed. |
pthread_sigmask()
int pthread_sigmask (int how, const sigset_t *__restrict set, sigset_t *__restrict oldset )
Description:
Checks or changes the signal mask of the calling thread.
Parameters:
how | Indicates the function behavior. |
set | Indicates the signal set to be changed. |
oldset | Used for returning the original mask set of the calling thread. |
Returns:
Returns 0 if the change is successful; returns errno as described below if the change fails.
The set or oldset points outside the process’s allocated address space. |
raise()
int raise (int signum)
Description:
Sends a signal to the calling process.
Parameters:
signum | Indicates the signal to be sent. |
Returns:
Returns 0 if the operation is successful; returns nonzero if the operation fails.
sem_close()
int sem_close ([sem_t]($api-api-SmartVision-Devices-sem_t.md) * sem)
Description:
Closes a specified semaphore.
Parameters:
sem | Indicates the pointer to the semaphore to close. |
Returns:
Returns 0 if the semaphore is closed. errno | Description
sem_destroy()
int sem_destroy ([sem_t]($api-api-SmartVision-Devices-sem_t.md) * sem)
Description:
Destroys a specified anonymous semaphore that is no longer used.
Parameters:
sem | Indicates the pointer to the semaphore to destroy. |
Returns:
Returns 0 if the destruction is successful.
sem_getvalue()
int sem_getvalue ([sem_t]($api-api-SmartVision-Devices-sem_t.md) *__restrict sem, int *__restrict sval )
Description:
Obtains the count value of a specified semaphore.
Parameters:
sem | Indicates the pointer to the semaphore. |
sval | Indicates the pointer to the obtained count value. |
Returns:
Returns 0 if the operation is successful.
sem_init()
int sem_init ([sem_t]($api-api-SmartVision-Devices-sem_t.md) * sem, int pshared, unsigned int value )
Description:
Creates and initializes an anonymous semaphore.
Parameters:
Returns:
Returns 0 if the initialization is successful; returns -1 and sets errno to a value in the following table if the initialization fails.
The input parameters are invalid and the initial count value exceeds the limit. |
sem_post()
int sem_post ([sem_t]($api-api-SmartVision-Devices-sem_t.md) * sem)
Description:
Increments the semaphore count by 1.
Generally, this function is used to increment the count of available shared resources when the process is to leave its critical section. This function is used together with sem_wait() to protect shared resources.
Parameters:
sem | Indicates the pointer to the semaphore to be operated. |
Returns:
Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.
sem_timedwait()
int sem_timedwait ([sem_t]($api-api-SmartVision-Devices-sem_t.md) *__restrict sem, const struct [timespec]($api-api-SmartVision-Devices-timespec.md) *__restrict timeout )
Description:
Obtains the semaphore, with a timeout period specified.
If the semaphore count is greater than 0, the shared resources can be obtained and the semaphore count decreases by 1. After the function returns 0, the code execution enters the resource critical area. Otherwise, the shared resource is unavailable, the function keeps waiting, and code execution cannot enter the resource critical area. If no semaphore is obtained within the specified timeout period, -1 is returned. This function is used together with sem_post() to protect shared resources.
Parameters:
sem | Indicates the pointer to the semaphore to be operated. |
timeout | Indicates the timeout period to be set. |
Returns:
Returns 0 if the semaphore is obtained; returns -1 and sets errno to a value in the following table if the semaphore fails to be obtained.
The semaphore is set to non-blocking mode, and the semaphore count is 0. |
|
sem_trywait()
int sem_trywait ([sem_t]($api-api-SmartVision-Devices-sem_t.md) * sem)
Description:
Attempts to obtain the semaphore.
If the semaphore count is greater than 0, the shared resources can be obtained and the semaphore count decreases by 1. After the function returns 0, the code execution enters the resource critical area. Otherwise, the shared resource is unavailable, and the function returns -1. This function is used together with sem_post() to protect shared resources.
Parameters:
sem | Indicates the pointer to the semaphore to be operated. |
Returns:
Returns 0 if the semaphore is obtained; returns -1 and sets errno to a value in the following table if the semaphore fails to be obtained.
The semaphore is set to non-blocking mode, and the semaphore count is 0. |
sem_unlink()
int sem_unlink (const char * name)
Description:
Deletes a specified semaphore.
This function is used to subtract 1 from the open count of the semaphore. If the open count is 0, this function deletes the semaphore.
Parameters:
name | Indicates the name of the semaphore to be deleted. |
Returns:
Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.
sem_wait()
int sem_wait ([sem_t]($api-api-SmartVision-Devices-sem_t.md) * sem)
Description:
Obtains the semaphore.
If the semaphore count is greater than 0, the shared resources can be obtained and the semaphore count decreases by 1. After the function returns 0, the code execution enters the resource critical area. Otherwise, the shared resource is unavailable, the function keeps waiting, and code execution cannot enter the resource critical area. This function is used together with sem_post() to protect shared resources.
Parameters:
sem | Indicates the pointer to the semaphore to be obtained. |
Returns:
Returns 0 if the semaphore is obtained; returns -1 and sets errno to a value in the following table if the semaphore fails to be obtained.
The semaphore is set to non-blocking mode, and the semaphore count is 0. |
sigaction()
int [sigaction]($api-api-SmartVision-Devices-sigaction.md) (int signum, const struct [sigaction]($api-api-SmartVision-Devices-sigaction.md) *__restrict act, struct [sigaction]($api-api-SmartVision-Devices-sigaction.md) *__restrict oldact )
Description:
Checks or changes the processing action associated with a specified signal. Do not use the process creation function or thread creation function in the registered callback processing function. Otherwise, the process is abnormal. For example, do not use the fork or pthread_create function.
Parameters:
signum | Indicates the signal to be operated. |
act | Indicates the new signal processing action. |
oldact | Indicates the original signal processing action if the value is not NULL. |
Attention:
The sa_flag field in act supports the SA_SIGINFO flag only.
Returns:
Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.
sigaddset()
int sigaddset (sigset_t * set, int signum )
Description:
Adds a signal to a specified signal set.
Parameters:
set | Indicates the pointer to the signal set to hold signals. |
signum | Indicates the signal to be added. |
Returns:
Returns 0 if the operation is successful. If set or signum is invalid, the process is abnormal.
sigandset()
int sigandset (sigset_t * dest, const sigset_t * left, const sigset_t * right )
Description:
Adds the intersection of left and right to dest.
Parameters:
dest | Indicates the pointer to the target signal set. |
left | Indicates the left set to be added. |
right | Indicates the right set to be added. |
Returns:
Returns 0 if the operation is successful.
sigdelset()
int sigdelset (sigset_t * set, int signum )
Description:
Delete a signal from a specified signal set.
Parameters:
set | Indicates the pointer to the signal set to hold signals. |
signum | Indicates the signal to be deleted. |
Returns:
Returns 0 if the operation is successful. If set or signum is invalid, the process is abnormal.
sigemptyset()
int sigemptyset (sigset_t * set)
Description:
Clears all signals in a specified signal set.
Parameters:
set | Indicates the pointer to the signal set to be cleared. |
Returns:
Returns 0 if the operation is successful. If set is invalid, the process is abnormal.
sigfillset()
int sigfillset (sigset_t * set)
Description:
Adds all signals to a specified signal set.
Parameters:
set | Indicates the pointer to the signal set to hold signals. |
Returns:
Returns 0 if the operation is successful. If set is invalid, the process is abnormal.
sighold()
int sighold (int signum)
Description:
Adds the signal specified by signum to the signal mask of the calling process.
Parameters:
signum | Indicates the signal to be added. |
Returns:
Returns 0 if the operation is successful; returns -1 if the operation fails.
sigisemptyset()
int sigisemptyset (const sigset_t * set)
Description:
Checks whether the signal set is empty.
Parameters:
set | Indicates the pointer to the signal set to be checked. |
Returns:
Returns 0 if the set is not empty; returns 1 if the set is empty; returns -1 if the operation fails.
sigismember()
int sigismember (const sigset_t * set, int signum )
Description:
Checks whether a signal is in the signal set.
Parameters:
set | Indicates the pointer to the signal set to be checked. |
signum | Indicates the signal to be checked. |
Returns:
Returns 0 if the signal is not in the set; returns 1 if the signal is in the set. If set or signum is invalid, the process is abnormal.
signal()
[sighandler_t]($api-api-SmartVision-Devices-IPC.md#ga754cdc0bcfffe07baa426dc252c9101a) signal (int signum, [sighandler_t]($api-api-SmartVision-Devices-IPC.md#ga754cdc0bcfffe07baa426dc252c9101a) handler )
Description:
Changes the processing action of a specified signal. Do not use the process creation function or thread creation function in the registered callback processing function. Otherwise, the process is abnormal. For example, do not use the fork or pthread_create function.
Parameters:
signum | Indicates the signal to be operated. |
handler | Indicates the pointer to the specified processing action (SIG_IGN or SIG_DFL, or to a custom processing action. |
Returns:
Returns the pointer to the original processing action if the operation is successful; returns SIG_ERR and sets errno to a value in the following table if the operation fails.
sigorset()
int sigorset (sigset_t * dest, const sigset_t * left, const sigset_t * right )
Description:
Adds the union set of left and right to dest.
Parameters:
dest | Indicates the pointer to the target signal set. |
left | Indicates the left set to be added. |
right | Indicates the right set to be added. |
Returns:
Returns 0 if the operation is successful.
sigpause()
int sigpause (int signum)
Description:
Deletes the signal specified by signum from the signal mask of the calling process and suspends the process until the signal is received.
Parameters:
signum | Indicates the signal to be operated. |
Attention:
After the signal is received, the original signal mask of the process is restored.
Returns:
Returns -1 and sets errno to a value in the following table.
sigpending()
int sigpending (sigset_t * set)
Description:
Obtains the signal suspended by the current thread.
Parameters:
set | Indicates the pointer to the signal set used to store the signal suspended by the current thread. |
Returns:
Returns 0 if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.
sigprocmask()
int sigprocmask (int how, const sigset_t *__restrict set, sigset_t *__restrict oldset )
Description:
Changes the signal mask of the calling thread.
Parameters:
how | Indicates the function behavior. |
set | Indicates the pointer to the signal set to be changed. |
oldset | Indicates the pointer to the original mask set of the calling thread. |
Returns:
Returns 0 if the change is successful; returns -1 and sets errno to a value in the following table if the change fails.
The set or oldset points outside the process’s allocated address space. |
sigrelse()
int sigrelse (int signum)
Description:
Deletes the signal specified by signum from the signal mask of the calling process.
Parameters:
signum | Indicates the signal to be deleted. |
Returns:
Returns 0 if the deletion is successful; returns -1 if the deletion fails.
sigsuspend()
int sigsuspend (const sigset_t * mask)
Description:
Sets mask as the signal mask set of the current process and suspends the process until a signal processing action is triggered.
Parameters:
mask | Indicates the pointer to the signal set to be set. |
Returns:
Returns -1 and sets errno to a value in the following table.
sigtimedwait()
int sigtimedwait (const sigset_t *__restrict set, siginfo_t *__restrict info, const struct [timespec]($api-api-SmartVision-Devices-timespec.md) *__restrict timeout )
Description:
Suspends the calling thread and waits for the signal, with a timeout period specified.
This function is used to suspend execution of the calling thread until one of the signals specified in the signal set becomes pending. This function specifies the timeout behavior.
Parameters:
set | Indicates the pointer to the signal set to be waited. |
info | Used to save the information about the waited signal if the value is not NULL. |
timeout | Indicates the timeout duration. |
Attention:
The signal to be waited must be in the mask set of the current thread. Once the signal is received, it is deleted from the pending list. The waiting for the signal cannot be interrupted by other signals, that is, EINTR is not supported.
Returns:
Returns the value of the waited signal if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails.
No signal specified by set is generated within the specified timeout period. |
|
sigwait()
int sigwait (const sigset_t *__restrict set, int *__restrict sig )
Description:
Suspends the calling thread and waits for the signal.
This function is used to suspend execution of the calling thread until one of the signals specified in the signal set becomes pending.
Parameters:
set | Indicates the pointer to the signal set to be waited. |
sig | Used for saving the waited signal. |
Attention:
The signal to be waited must be in the mask set of the current thread. Once the signal is received, it is deleted from the pending list.
Returns:
Returns 0 if the signal is received; returns -1 and sets errno to a value in the following table if the signal fails to be received.
sigwaitinfo()
int sigwaitinfo (const sigset_t *__restrict set, siginfo_t *__restrict info )
Description:
Suspends the calling thread and waits for the signal, with a timeout period specified.
This function is used to suspend execution of the calling thread until one of the signals specified in the signal set becomes pending. This function does not specify the timeout behavior.
Parameters:
set | Indicates the pointer to the signal set to be waited. |
info | Used to save the information about the waited signal if the value is not NULL. |
Attention:
The signal to be waited must be in the mask set of the current thread. Once the signal is received, it is deleted from the pending list. The waiting for the signal cannot be interrupted by other signals, that is, EINTR is not supported.
Returns:
Returns the value of the waited signal if the operation is successful; returns -1 and sets errno to a value in the following table if the operation fails. errno | Description ———|——————————————-—