[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Groff] Re: [Mingw-users] Problems Building "GROFF" with MinGW
From: |
Earnie Boyd |
Subject: |
[Groff] Re: [Mingw-users] Problems Building "GROFF" with MinGW |
Date: |
Fri, 18 Jul 2003 12:50:14 -0400 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130 |
MARSHALL Keith wrote:
I haven't really looked into this yet, but I already know how to fix the
"mkdir" problem, and I expect to find the "fork" and "wait" will be
coupled with an "exec...", which I can replace with the corresponding
"spawn..." -- do I need to #include <process.h>, as I used to with MSC-6?
Any tips on implementing an equivalent of the "pipe" function, or will
this
depend on how "do_html" is using it?
The waitpid() is pretty easy:
#define waitpid(a,b,c) _cwait(b,a,c)
_cwait() is declared in process.h.
For pipe:
#include <fcntl.h>
#define pipe(a) _pipe((a), 0, _O_BINARY | _O_NOINHERIT)
Now let's create a pipe for stdin:
#include <stdio.h>
int parent_stdin;
int pfd[2];
int child;
if (pipe (pfd) < 0)
error ...;
if ((parent_stdin = dup (STDIN_FILENO)))
error ...;
_setmode (parent_stdin, _O_NOINHERIT);
if (dup2 (pfd[0], STDIN_FILENO) < 0)
error ...;
if ((child = spawn...) < 0)
error ...;
if (dup2 (parent_stdin, STDIN_FILENO) < 0)
error ...;
close (parent_stdin);
close (pfd[1]);
Now you can write to pfd[0]. A \r\n should be converted to \n. Make
sure you flush thd pipe. For reading the child stdout pipe, you will
need to do character based reads to avoid blocking. Search the web for
more examples.
Earnie.