mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2025-12-30 21:10:09 +01:00
util: Add a wrapper for dup() and pipe2()
The wrappers take care of blocking the SIGALRM signal. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
This commit is contained in:
parent
0ac9b1b02d
commit
0d3a398fee
1 changed files with 26 additions and 0 deletions
|
|
@ -152,6 +152,32 @@ xsend(int fd, const void *buf, size_t len)
|
|||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around pipe2() that always blocks the SIGALRM signal.
|
||||
*/
|
||||
static inline int
|
||||
xpipe2(int pipefd[2], int flags)
|
||||
{
|
||||
sigset_t old_mask = signals_block();
|
||||
int n = pipe2(pipefd, flags);
|
||||
signals_release(old_mask);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around dup() that always blocks the SIGALRM signal.
|
||||
*/
|
||||
static inline int
|
||||
xdup(int fd)
|
||||
{
|
||||
sigset_t old_mask = signals_block();
|
||||
int n = dup(fd);
|
||||
signals_release(old_mask);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around send() that always sets MSG_NOSIGNAL and allows appending
|
||||
* file descriptors to the message.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue