Hi Adam,

On 09/24/2018 01:55 PM, Adam Borowski wrote:
> Hi!
> It looks like mingw adds more and more POSIX functions to the crt.
> For example, gettimeofday() is now misc/gettimeofday.c, etc.
>
> Thus, what about pipe()?  I noticed that in the "compat" part of a program
> of mine the only piece still used is:
>
> #ifndef HAVE_PIPE
> int pipe(int p[2])
> {
>     if (!CreatePipe((PHANDLE)p, (PHANDLE)p+1, 0, 0))
>         return -1;
>     p[0]=_open_osfhandle(p[0],0);
>     p[1]=_open_osfhandle(p[1],0);
>     return 0;
> }
> #endif
>
> The semantics of _open_osfhandle() are what we want -- those HANDLEs go away
> when the file descriptors get close()d.
>
> I don't think CreatePipe() sets errno, but translating GetLastError()
> shouldn't be rocket surgery.
>
> I'm not providing a proper patch yet, as I'd need to learn your build system
> -- thus asking first.

Windows crt provides _pipe function that you may use.

Jacek


_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to