Blame gnulib/tests/pipe.c
|
Packit Service |
a2ae7a |
/* Create a pipe.
|
|
Packit Service |
a2ae7a |
Copyright (C) 2009-2019 Free Software Foundation, Inc.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
a2ae7a |
it under the terms of the GNU General Public License as published by
|
|
Packit Service |
a2ae7a |
the Free Software Foundation; either version 3, or (at your option)
|
|
Packit Service |
a2ae7a |
any later version.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
This program is distributed in the hope that it will be useful,
|
|
Packit Service |
a2ae7a |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
a2ae7a |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
a2ae7a |
GNU General Public License for more details.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
You should have received a copy of the GNU General Public License along
|
|
Packit Service |
a2ae7a |
with this program; if not, see <https://www.gnu.org/licenses/>. */
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
#include <config.h>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* Specification. */
|
|
Packit Service |
a2ae7a |
#include <unistd.h>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
#if defined _WIN32 && ! defined __CYGWIN__
|
|
Packit Service |
a2ae7a |
/* Native Windows API. */
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* Get _pipe(). */
|
|
Packit Service |
a2ae7a |
# include <io.h>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
/* Get _O_BINARY. */
|
|
Packit Service |
a2ae7a |
# include <fcntl.h>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
int
|
|
Packit Service |
a2ae7a |
pipe (int fd[2])
|
|
Packit Service |
a2ae7a |
{
|
|
Packit Service |
a2ae7a |
/* Mingw changes fd to {-1,-1} on failure, but this violates
|
|
Packit Service |
a2ae7a |
http://austingroupbugs.net/view.php?id=467 */
|
|
Packit Service |
a2ae7a |
int tmp[2];
|
|
Packit Service |
a2ae7a |
int result = _pipe (tmp, 4096, _O_BINARY);
|
|
Packit Service |
a2ae7a |
if (!result)
|
|
Packit Service |
a2ae7a |
{
|
|
Packit Service |
a2ae7a |
fd[0] = tmp[0];
|
|
Packit Service |
a2ae7a |
fd[1] = tmp[1];
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
return result;
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
#else
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
# error "This platform lacks a pipe function, and Gnulib doesn't provide a replacement. This is a bug in Gnulib."
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
#endif
|