delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/11/25/13:10:17

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED
X-Spam-Check-By: sourceware.org
From: Devin Nate <devin DOT nate AT cloudwerx DOT com>
To: LMH <lmh_users-groups AT molconn DOT com>
CC: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: Re: Replacing fork/exec with spawn question
Date: Sun, 25 Nov 2012 18:09:08 +0000
Message-ID: <1ABB64C8-E5F7-4157-936A-FCB262C955F8@cloudwerx.com>
References: <5561519E-4216-47A7-A020-EF2EA8E45A56 AT cloudwerx DOT com>,<50B251D7 DOT 7010501 AT molconn DOT com>
In-Reply-To: <50B251D7.7010501@molconn.com>
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id qAPIADMh019344

Hi LMH,

Fair enough, although I had understood that mixing native Windows functions and cygwin was not a good practice? (Although i have no idea if thats the only option). I will be using ifdefs, and I don't need it abstracted such that I have 2 functions named the same.

I just have a handful of fork/exec's I'd like to fix to be most cygwin friendly.

Thanks,
Devin Nate



On Nov 25, 2012, at 10:14 AM, "LMH" <lmh_users-groups AT molconn DOT com> wrote:

> 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
> 

--
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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019