0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 01:31:55 +00:00

Birdloop pipe is set O_CLOEXEC.

If we decide to exec something, we shouldn't pass along our intenal fds.
This commit is contained in:
Maria Matejka 2024-10-02 19:02:53 +02:00
parent 0eb1548cc4
commit 169677deeb
2 changed files with 13 additions and 2 deletions

View File

@ -281,6 +281,8 @@ sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '`"
AC_MSG_RESULT([$sysdep_dirs])
AC_SUBST([sysdep_dirs])
AC_CHECK_FUNCS([pipe2])
if test "$with_iproutedir" = no ; then with_iproutedir= ; fi
if test -n "$given_iproutedir"

View File

@ -4,6 +4,8 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -195,15 +197,22 @@ birdloop_in_this_thread(struct birdloop *loop)
void
pipe_new(struct pipe *p)
{
int flags = O_NONBLOCK | O_CLOEXEC;
#if HAVE_PIPE2
int rv = pipe2(p->fd, flags);
if (rv < 0)
die("pipe2: %m");
#else
int rv = pipe(p->fd);
if (rv < 0)
die("pipe: %m");
if (fcntl(p->fd[0], F_SETFL, O_NONBLOCK) < 0)
if (fcntl(p->fd[0], F_SETFL, flags) < 0)
die("fcntl(O_NONBLOCK): %m");
if (fcntl(p->fd[1], F_SETFL, O_NONBLOCK) < 0)
if (fcntl(p->fd[1], F_SETFL, flags) < 0)
die("fcntl(O_NONBLOCK): %m");
#endif
}
void