X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Eric Blake Subject: Re: Excessive thrashing when popen()ing after a large malloc() Date: Wed, 15 Nov 2006 20:31:49 +0000 (UTC) Lines: 32 Message-ID: References: <20061115200351 DOT DB4C514425F7 AT u53026a DOT matapp DOT unimib DOT it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Loic Grenie matapp.unimib.it> writes: > That intermediate sh invocation can probably be slightly streamlined > by doing something similar to > > sprintf(cmd, "(%s) >&%d %d>&- %d>&-", program, pdes[1], pdes[0], pdes[1]); > pid = spawnl(_P_NOWAIT, _PATH_BSHELL, "sh", "-c", cmd, NULL); Nope. Still one fork too many due to the use of a subshell, still mishandles any ' in program, and regresses in robustness since it would mishandle a program such as "echo hi);(:" that is currently rejected by popen. > > but you misunderstand my objective: I'm not "trying to have my patch > accepted", I'm just signaling a problem and proposing a patch for the > upstream maintainers: cygwin and/or newlib. I've modified the program > that uses popen and it is now using a _popen which is a kludge around > the ideas that I have suggested. If my ideas are useful for anybody else, > I'm really happy to contribute and help; if nobody cares, neither do I. Indeed, ANY time you don't like what the standard library provides, you are ALWAYS welcome to write your own replacement that suits your needs (and that goes for more than just popen). And the fact that you reported to this list is a good thing, as it looks like you spurred some developmental ideas. In other words, we do care about performance, but we also care about maintainability, standards documents, and backwards compatibility; it's not easy to balance all of these (sometimes competing) objectives. I'll just wait to see the patch that cgf has in his sandbox. -- Eric Blake -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/