[SDL] pipe with other process
Chris Nystrom
cnystrom at gmail.com
Fri Dec 17 05:14:01 PST 2004
On Fri, 17 Dec 2004 12:22:08 +0100, emanuele.dalmasso at libero.it
<emanuele.dalmasso at libero.it> wrote:
> Hi,
>
> I've a dos program written by me some times ago, and now I would like to
> write a grafic
> interface to it with SDL. But I want to write the GUI as a separate
> program, now I was
> thinking about to run my SDL application and in this launch my program and
> make
> communication between these 2 process with a redirection of standard
> input-output.
Since this is 2-way communications it is actually fairly complicated.
In unix you would have
to create a stream pipe, and then fork off a new process (using the
pipe for IPC), dup() the file descriptors, and then run one of the
exec family of system calls.
Since you have a DOS app, I assume you want to do this with MS
Windows, and not a DOS emulator. I am not sure how Windows does it,
but I believe fork() is pretty much unix specific, so it looks to me
like any solution will be OS specific and not portable.
> So my question are:
> - how can I run my dos program within sdl application?There is some ad'Oc
> command or
> have I to usa something like system()?
The problem with system() is that your app is no longer in control
when you run it. If your app was something that you could just go run,
and then read the output and process, then that would work fine.
> - How can I create a pipe to make my 2 process communicate each other?
> I want to connect stdout of one with stdin of the other and viceversa,
> There is something supported by SDL or have I to use system call?
I believe you will have to use a few system calls.
> Thanks in advance.
Welcome,
Chris
--
Chris Nystrom <cnystrom at gmail.com>
http://www.newio.org/~ccn
AIM: nystromchris
More information about the SDL
mailing list