Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Tor Lillqvist <tml-X3B1VOXEql0 <at> public.gmane.org>
Subject: Re: pipe(2) implementation for mingw
Newsgroups: gmane.comp.gnu.mingw.user
Date: Friday 19th December 2008 10:15:20 UTC (over 8 years ago)
> Is there a pipe(2) implementation in mingw?

Yes and no. There is a _pipe() function in the Microsoft C library
that mingw-compiled code uses. (And it is implemented using
lower-level functions in the Win32 API, obviously.)

It is not fully equivalent to the pipe(2) POSIX system call, as
Windows is not and does not claim to be POSIX, and mingw doesn't claim
to make it look like POSIX. The fact that there is much POSIX-inspired
functionality in the Microsoft C library does not change this. (I mean
functions like open(), close(), dup(), read(), write(), and indeed
_pipe().)

Its parameter list is different. Typically something like this is useful:

#define pipe(fds) _pipe(fds,4096, _O_BINARY)

I.e. this defines pipe() as a macro that calls _pipe() to create a
pipe with buffer size 4096 and in binary mode. (The distinction
between "binary" and "text" mode, which relates to the handling of \n,
is specific to file descriptors in the Microsoft C library, the
underlying Win32 API has no such distinction.)

> If there's not, shouldn't it be easy to emulate it using a tcp socket on
> localhost?

Not really, as you then would have sockets, not file descriptors. You
can't write to / read from sockets using write() / read(), for
instance. Sockets and file descriptors are not the same thing at all
on Windows.

> I haven't delved into the CreateNamedPipe call yet...

CreateNamedPipe() is not the API used to create the Win32 anonymous
pipes that _pipe() uses. Win32 named pipes are not like POSIX pipes
(or POSIX named pipes) at all. It is CreatePipe() that you want to
look at, if you want something like POSIX pipes. (Or then, as I said,
just use _pipe() from the C library.)

--tml

------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
[email protected]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

_______________________________________________
This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.
 
CD: 3ms