system() always returns 0?

Mark Alexander alexande at drivax.DRI
Wed Jan 25 03:56:20 AEST 1989


One possible solution to the problem of COMMAND.COM always returning
zero is that used by NDMAKE.  The basic idea is to construct on the
fly a little batch file that gets passed to COMMAND.COM.  Before you
call system(), though, you create a little zero-length temporary file.
The batch file runs the subprogram, then checks the errorlevel.  If
the errorlevel is 0, it deletes the temporary file.  Then the main
program gets control again and checks the existence of the temporary
file: if it still exists, an error occurred.

The batch file would look something like this:
	prog [parms...] [<infile] [>outfile]
	if errorlevel 1 goto done
	del tempfile
	:done
-- 
Mark Alexander	(amdahl!drivax!alexande)



More information about the Comp.lang.c mailing list