delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/09/08/09:13:15

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT sourceware DOT cygnus DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-ID: <19990908130937.30173.qmail@hotmail.com>
X-Originating-IP: [24.228.44.77]
From: "Le Roi" <xdiv AT hotmail DOT com>
To: cygwin AT sourceware DOT cygnus DOT com
Subject: fork & exec -> crash
Date: Wed, 08 Sep 1999 09:09:37 EDT
Mime-Version: 1.0

I'm trying to write a simple program that will fork and exec another 
program.  When I run it, it sometimes runs the child program, and sometimes 
does not, but always gets a Windows "This program has performed an illegal 
operation and will be shut down" message.  Here is my program:

int
main(int argc, char **argv)
{
	int	pid;

	if (argc == 1) {
		printf("Must specify command to run.\n");
		return (1);
	}

	if ((pid = fork()) == -1) {
		perror("fork");
		return (1);
	} else if (pid == 0) {
		execv(argv[1], &argv[1]);
		_exit(1);
	} else {
		printf("parent exiting\n");
		_exit(0);
	}

	return (0);
}

Note that if I comment out the fork code and just call the execv line, it 
correctly execs without crashing.  Also note that I got the same behavior 
when I was calling exit instead of _exit.

And here is my the "details" of the crash:

SPAWN caused an invalid page fault in
module KERNEL32.DLL at 015f:bff77042.
Registers:
EAX=0257f0e0 CS=015f EIP=bff77042 EFLGS=00010213
EBX=0000003c SS=0167 ESP=0257f00c EBP=0257fd24
ECX=d28268e0 DS=0167 ESI=0000001f FS=0000
EDX=00000000 ES=0167 EDI=0257fa04 GS=0000
Bytes at CS:EIP:
64 ff 35 00 00 00 00 64 89 25 00 00 00 00 8b 4c
Stack dump:
bffa18e8 6102d45b 0000003c 0257fa04 00000208 0257f0e0 00000000 00000000 
0257fdd5 79616c70 6e756f73 6c702e64 756f7320 2f73646e 6d696863 772e7365

Thanks,

Adam

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


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