c - Why can't I test the return code in Windows 7? -


I have a very complex program that is failing, and I tested it with a batch file and C Simplified in the set. Program

My C program uses ExitProcess to pass the error level in the batch file, sometimes at Windows 7 (Microsoft Windows [version 6.1.7600]), the error level is not interpreted correctly is being done.

I think that it should run forever on Windows XP, it seems to run forever, this is a few minutes on two different dual-core Windows 7 machines (one 64-bit one 32-bit) Fails within

I do not think I am doing something wrong, but if there is something weird about ExitProcess on Windows 7, I thought I would ask. Is there anything here that I have done illegally?

Test.bat for the batch file cmd.exe:

  @ECHO OFF SET I = 0: Pass Set / AI Pass = Ile + 1 Title% I% Start / wait level250 error level 251 fails fail if error level 250 passes: pass  

program level250.c:

  # "windows .h "include steady volatile int terminal = 0; Static unsigned __stdcall TestThread (zero * unused) {end = 1; Return 0; } WINAPI WinMain (Histyine H Instance, Histnea H Preve Instance, LPTRS LPS's CMDline, Int NCMD Show) {Createthread (Zero, 0, Testthread, Zero, 0, Faucet); While (end == 0) sleep (1); ExitProcess (250); }  

My compiler version and orientation are:

For Microsoft (R) 32-bit C / C ++ adapter compiler version 12.00.8804 80x86

Copyright (c) Microsoft Corp 1984-1998 All Rights Reserved.

CL / MT level 250C

Other information: I have also tried to run under JSPoft TCC and treated the same as using CMD . I straighten c I'm using C program, no. I do not see any failure in the same threaded version of CPP; I put the sources and binaries and the zip file is MD5 579F4FB15FC7C1EA454E30FDEF97C16B and CRC32 C27CB73D.

After the suggestions edit , I have changed the case of further testing and still see the failures in our actual application, there are hundreds of threads. Some threads come out with various significant return codes, run some runs forever, and some operating systems are placed in call or DLL and have to hit hard (if not impossible).

  # include "windows.h" static unsigned __stdcall testtrade (zero * unused) {return 0; } WINAPI WinMain (Histyine H Instance, Histnea H Preve Instance, LPTRS LPS's CMDline, Int NCMD Show) {Createthread (Zero, 0, Testthread, Zero, 0, Faucet); Return (250); }  

No guarantee in what the print code is actually It is not that if anything goes wrong, then you are expected 251 and 250, as if about the fault of division, or other errors which you do not know, besides I can not see that you have 251 Where are you returning. Beware of high exhaust codes, I believe 255 is a safe portable limit, on some systems this may be less than 64, or & lt; = 127. (This can be clearly irrelevant to see because you are clearly using Windows but it is worth noting.)

In addition to this process' unexpected death, a debugger , Or try to load the core dump.


Comments