mirror of
https://github.com/curl/curl.git
synced 2026-08-25 02:03:36 +03:00
wakeup_create: use FD_CLOEXEC/SOCK_CLOEXEC
for `pipe()`/`socketpair()` Fixes #13618 Closes #13625
This commit is contained in:
parent
6eee810db4
commit
fd0d2ed74a
3 changed files with 41 additions and 5 deletions
|
|
@ -27,6 +27,27 @@
|
|||
#include "urldata.h"
|
||||
#include "rand.h"
|
||||
|
||||
#if defined(HAVE_PIPE) && defined(HAVE_FCNTL)
|
||||
#include <fcntl.h>
|
||||
|
||||
int Curl_pipe(curl_socket_t socks[2])
|
||||
{
|
||||
if(pipe(socks))
|
||||
return -1;
|
||||
|
||||
if(fcntl(socks[0], F_SETFD, FD_CLOEXEC) ||
|
||||
fcntl(socks[1], F_SETFD, FD_CLOEXEC) ) {
|
||||
close(socks[0]);
|
||||
close(socks[1]);
|
||||
socks[0] = socks[1] = CURL_SOCKET_BAD;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(HAVE_SOCKETPAIR) && !defined(CURL_DISABLE_SOCKETPAIR)
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue