Is mq_send atomic?

can someone tell me what happens if a multi-threaded program receives a SIGSTOP signal during mq_send execution?

+4
source share
1 answer

The manual page for mq_send indicates that it is implemented on top of mq_timedsend , which is a Linux system call. System calls are usually atomic because they either succeed or not. If the system call is interrupted by a signal, the usual behavior is to return -1 and set errno to EINTR . It seems that mq_send has this behavior.

Basically, you should check the EINTR and retry the call if it doesn't work that way. This is especially important for system calls that can block as recv or select , since they have a higher chance of interruption.

+2
source

All Articles