This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Excessive thrashing when popen()ing after a large malloc()

Loic Grenie <grenie <at>> 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:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]