popen problems

David J. Slate dslate@interaccess.com
Sat Sep 6 07:32:00 GMT 1997


To: gnu-win32@cygnus.com
Reply-To: dslate@interaccess.com
Subject: popen problems

I recently installed the gnu-win32 package (b18, with development tools) on
my DELL PentiumII box running Windows-95.  I got a simple "Hello, world!"
program to compile and run with gcc, and am now trying to port a complex
application from a Linux/Unix environment.  I'm having a problem with popen,
which seems to fail consistently.  For example, compiling and running the
following program:

--------------------------------------------------------------------------
	#include <stdio.h>
	#include <stdlib.h>
	#include <string.h>

	int
	main( int argc, char *argv[])
	{
		char	s[ 1000],
			*t;
		FILE	*fp;
		
		fp = popen( "cat >zfile", "w");
		if (! fp)
			exit( 1);
		fprintf( fp, "Hello, World!\n");
		return (0);
	}
--------------------------------------------------------------------------

produces the following on stderr:

	(C:\TMP\A.EXE 1111) In cygwin_except_handler
	(C:\TMP\A.EXE 1111) Exception trapped!
	(C:\TMP\A.EXE 1111) exception C0000005 at BFF76EF6
	(C:\TMP\A.EXE 1111) exception: ax 81605000 bx 82BA8C38 cx C30 dx 0
	(C:\TMP\A.EXE 1111) exception: si 816221D4 di E bp 253ECA0 sp 253E574
	(C:\TMP\A.EXE 1111) exception is: STATUS_ACCESS_VIOLATION
	(C:\TMP\A.EXE 1111) Stack trace:
	(C:\TMP\A.EXE 1111) frame 0: sp = 0x253E38C, pc = 0x1000CEC2
	(C:\TMP\A.EXE 1111) frame 1: sp = 0x253E3A8, pc = 0xBFF76780
	(C:\TMP\A.EXE 1111) frame 2: sp = 0x253E3CC, pc = 0xBFF858F3
	(C:\TMP\A.EXE 1111) frame 3: sp = 0x253E464, pc = 0xFFECBAD7
	(C:\TMP\A.EXE 1111) frame 4: sp = 0x253ECA0, pc = 0x1000D776
	(C:\TMP\A.EXE 1111) frame 5: sp = 0x253ECDC, pc = 0x10026A39
	(C:\TMP\A.EXE 1111) frame 6: sp = 0x253F0F0, pc = 0x1002876F
	(C:\TMP\A.EXE 1111) frame 7: sp = 0x253F120, pc = 0x401079
	(C:\TMP\A.EXE 1111) frame 8: sp = 0x253F520, pc = 0x1000C102
	(C:\TMP\A.EXE 1111) frame 9: sp = 0x253FE0C, pc = 0x1000C113
	(C:\TMP\A.EXE 1111) frame 10: sp = 0x253FE18, pc = 0x40120D
	(C:\TMP\A.EXE 1111) frame 11: sp = 0x253FE28, pc = 0x40103B
	(C:\TMP\A.EXE 1111) frame 12: sp = 0x253FE38, pc = 0xBFF88E93
	(C:\TMP\A.EXE 1111) frame 13: sp = 0x253FF78, pc = 0xBFF88D41
	(C:\TMP\A.EXE 1111) frame 14: sp = 0x253FFF4, pc = 0xBFF87759
	(C:\TMP\A.EXE 1111) frame 15: sp = 0x81621EE0, pc = 0x4
	(C:\TMP\A.EXE 1111) End of stack trace (more stack frames may be present)

Here is the output from the set command, to show my environmental vars:

	!C:=C:\tmp
	BASH=/GNUWIN32/B18/H-I386~1/BIN/BASH.EXE
	BASH_VERSION=1.14.7(2)
	BLASTER=A220 I5 D1 T4
	CMDLINE=bash
	COMSPEC=C:\WINDOWS\COMMAND.COM
	EUID=500
	GCC_EXEC_PREFIX=C:\gnuwin32\b18\H-i386-cygwin32\lib\gcc-lib\
	GDBTK_LIBRARY=C:/gnuwin32/b18/share/gdbtcl
	HISTFILE=/.bash_history
	HISTFILESIZE=500
	HISTSIZE=500
	HOSTTYPE=i386
	IFS= 	
	
	MAILCHECK=60
	MSINPUT=C:\MSINPUT
	OPTERR=1
	OPTIND=1
	OSTYPE=win32
	PATH=/WINDOWS:/windows:/windows/COMMAND:/LOCAL/BIN:/GNUWIN32/B18/H-I386-CYGWIN32/BIN:/GNUWIN32/B18/TCL/BIN
	PPID=1000
	PROMPT=$p$g
	PS1=bash\$ 
	PS2=> 
	PS4=+ 
	PWD=/TMP
	SHELL=/bin/sh
	SHLVL=1
	TCL_LIBRARY=C:/gnuwin32/b18/tcl/lib/tcl7.6
	TEMP=C:\windows\TEMP
	TERM=dumb
	TMP=c:\windows\TEMP
	UID=500
	WINBOOTDIR=C:\WINDOWS
	WINDIR=C:\WINDOWS
	_=pwd

I have tried system(), and that seems to work.  Is popen supposed to work,
and, if so, do you have any idea why it is failing?

Thanks,

-- Dave Slate
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".



More information about the Cygwin mailing list