Mail Archives: cygwin/2005/01/11/14:29:19
--vtzGhvizbBRQ85DL
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Tue, Jan 11, 2005 at 02:21:22PM +0100, Rainer Hochreiter wrote:
> > On Mon, Jan 10, 2005 at 08:56:58AM +0100, Rainer Hochreiter wrote:
> >> but what's the real reason why popen() results in the address
> >> conflict and system() does not?!
> >
> > AFAICT, popen() calls fork() and system() does not.
>
> this is not true - both functions call vfork()!
>
> cygwin-1.5.12-1/newlib/libc/stdlib/system.c:165 if ((pid = vfork ()) == 0)
AFAICT, Cygwin's system() is implemented in:
winsup/cygwin/syscalls.cc
> system() calls execve() while popen() calls execl() to start execution
> of another file!
Nevertheless, the above is not quite right. fork() is called, but the
call occurs in sh *not* the original application. See the attached
testcase, st.c, and the following strace snippets:
$ strace st | egrep '(Program name| fork):'
Program name: c:\home\jtishler\src\c++\st.exe (2788)
Program name: C:\cygwin\bin\sh.exe (928)
227 17561 [main] sh 928 fork: entering
Program name: C:\cygwin\bin\sh.exe (4948)
199 42119 [main] sh 928 fork: 4948 = fork()
151 43337 [main] sh 4948 fork: 0 = fork()
Program name: C:\cygwin\bin\id.exe (4948)
This is why system() does not trigger the base address conflict problem
and popen() does.
Jason
--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6
--vtzGhvizbBRQ85DL
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="st.c"
#include <stdlib.h>
int
main()
{
system("id");
return 0;
}
--vtzGhvizbBRQ85DL
Content-Type: text/plain; charset=us-ascii
--
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/
--vtzGhvizbBRQ85DL--
- Raw text -