Xref: utzoo comp.sys.ibm.pc:23760 comp.lang.c:15790 Path: utzoo!attcan!uunet!pilchuck!dataio!bright From: bright@Data-IO.COM (Walter Bright) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Re: system() always returns 0? Keywords: MSC5.0 Message-ID: <1844@dataio.Data-IO.COM> Date: 25 Jan 89 19:51:41 GMT References: <782@hawkmoon.MN.ORG> Reply-To: bright@dataio.Data-IO.COM (Walter Bright) Organization: Data I/O Corporation; Redmond, WA Lines: 14 In article <782@hawkmoon.MN.ORG> det@hawkmoon.MN.ORG (Derek E. Terveer) writes: >Has anyone encountered a problem with the Microsoft C 5.0 compiler always >returning a 0 from the system() call, no matter what the actual command >executed by system() returns? system("command") on MS-DOS is usually implemented by running COMMAND.COM with the argument "/c command". The system() call returns the value that COMMAND.COM returns. COMMAND.COM does not return the exit status of the command that it executed, so it's a DOS bug, not a compiler library bug. The correct solution is to use the spawn() function. spawn() also uses less memory and executes faster than system(). The only caveats are that spawn() cannot execute COMMAND.COM's built-in commands like TYPE and DIR, and spawn() does not do the < | > redirection.