Subject: Re: fork & exec -> crash
From: Chris Faylor <[email-masked]>
To: Le Roi <[email-masked]>
Cc: [email-masked]
Date: Fri, 10 Sep 1999 21:56:17 -0400

It sounds like you're running on Windows 95 or 98.

This problem has been reported in the past.  As near as I can tell,
it's some kind of strange Windows problem.  I have a test program
that does roughly the same thing but if I put a sleep(2) in the
parent process, just before it exits, things seem to work.

I'll probably fix this at some point.  In the meantime, as always,
"a fix would be gratefully accepted."

-Chris Faylor
-Win32 Manager
-Cygnus Solutions

On Wed, Sep 08, 1999 at 09:09:37AM -0400, Le Roi wrote:
>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 [email-masked]
>

-- 
[email-masked]
http://www.cygnus.com/

--
Want to unsubscribe from this list?
Send a message to [email-masked]