Date: Wed, 26 Feb 1997 14:19:44 +0200 (IST) From: Eli Zaretskii To: chojnacki cc: djgpp AT delorie DOT com Subject: Re: strange thing with exit(0) In-Reply-To: <199702252042.VAA04335@ernie.icslab.agh.edu.pl> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 25 Feb 1997, chojnacki wrote: > I've encountered very strange something. > After compiling enclosed below code with: > gcc -o foo foo.c > program hangs in function exit() ("Hello!" is printed). > Function flushKeyboard is guilty but I don't know why. The real strange thing is that your program at all works, because you don't zero out the SS and SP members of the registers: > void flushKeyboard() > { > _go32_dpmi_registers r; > r.h.ah=0x0c; > r.h.al=0; r.x.ss = r.x.sp = r.x.flags = 0; <<<<<<<<<<<<<<<<<< missing line > _go32_dpmi_simulate_int(0x21,&r); > } The line marked ``missing'' should make the program work. The DJGPP FAQ list explains this in section 18.3. > The more strange thing is that program hangs only if > the name of the coff file is three characters long. > If I rename "foo" for e.g. "foo1" and run "go32 foo1" > everything is O.K. > I found also that if I remove line: > SHELL=C:\COMMAND.COM C:\ /E:2000 /P > from my config.sys file program works fine. Since you don't zero SS:SP, they point to random memory location, and slight changes in the program and/or environment migh prevent it from crashing.