Replacing fork/exec with spawn question

LMH lmh_users-groups@molconn.com
Sun Nov 25 17:14:00 GMT 2012


You will need to use windows pipes as well as the windows version of 
fork. I have a couple of small apps that do what you are suggesting.

What I did was to abstract the functions for creating process and pipes. 
Abstraction was done in the make file. There are functions like 
create_new_process(), create_new_pipe(), etc. There are two versions 
(posix and windows) of each function with the same name, but in 
different src files. When the app is built, one or the other version of 
the src file is linked, depending on what os you are in (dual-boot etc). 
This lets you build your app on multiple platforms from the same code 
base. This could be done with ifdef or other compiler tools as well.

I don't know if I have time today, but I can put together some of the 
code for you to look at. Suffice it to say that I have cpp apps that 
work as you suggest, parent/child with pipes for IPC, and they were 
built for windows using cygwin. They also run under linux if that matters.

It may be better to move such a discussion to a programing board since 
some of this will not relate to cygwin and it would be nice to have 
things like php formatted code, attachments, etc. The mods here can let 
us know about that. I have thought at times that some of the code I have 
here should be made into some kind of IPC API. Perhaps others would find 
that useful.

LMH

Devin Nate wrote:
> Hi folks,
>
> I'm looking for some documentation about the cygwin spawn use, or a recommendation of a package that has had fork/exec replaced by spawn that I can review to see how someone else did it. Preferably less intimidating than gcc, and which uses pipes for IPC between parent and child.
>
> In particular, the code I'm looking to patch does a typical fork/exec and uses 2 pipes to communicate bi-directionally parent to child. The pipes are throwing me off as to if cygwin spawn is usable.
>
> I've been through the spawn.cc code, and see spawn_guts has a concept of __stdin and __stdout, but I don't see those params used by any of the spawn functions.
>
> Any help or pointers to code or docs appreciated.
>
> Thank you,
> Devin Nate
>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>
>

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list