Xref: utzoo comp.sys.ibm.pc:23750 comp.lang.c:15783 Path: utzoo!attcan!uunet!mcvax!hp4nl!eutrc3!wzv!wietse From: wietse@wzv.UUCP (Wietse Z. Venema) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Re: system() always returns 0? Keywords: MSC5.0 Message-ID: <188@wzv.UUCP> Date: 24 Jan 89 20:53:44 GMT References: <782@hawkmoon.MN.ORG> Reply-To: wietse@wzv.UUCP (Wietse Z. Venema) Organization: Eindhoven University of Technology, The Netherlands Lines: 22 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? Command.com always returns a zero status. There are two alternatives: (a) Do not use a shell, but use the spawnlp() functions. These are similar to the unix execlp() functions, but instead of over- laying the calling process they just suspend it. (b) Use a different shell. This may not be practical if your program is to be used on other machines. In case of alternative (a) you will have to do your own i/o redirection handling. Caveat: in some cases I had to save the positions of all stdio streams open for reading from files, and restore them after the system() routine terminated. -- work: wswietse@eutrc3.uucp | Eindhoven University of Technology work: wswietse@heitue5.bitnet | Mathematics and Computing Science home: wietse@wzv.uucp | 5600 MB Eindhoven, The Netherlands