system() always returns 0?

Steve Mawer scm at datlog.co.uk
Thu Jan 26 22:22:42 AEST 1989


In article <782 at hawkmoon.MN.ORG> det at 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?
>
>and i'm having a hard time of it since system() always (seems) to return 0!
>

According to my Microsoft manual "The system function returns the value
0 if string is successfully executed.  A return value of -1 indicates an
error ..." and cites the error reasons as being

    E2BIG   - arg list > 128 bytes or env info >32K
    ENOENT  - can't find COMMAND.COM
    ENOEXEC - COMMAND.COM file can't be executed
    ENOMEM  - insufficient memory to execute the command, etc.

What it returns is whether its exec succeeded, not the exec'd command's
status.  I have been burned by this problem, too, and haven't got a
solution. (Anyone?)

-- 
Steve C. Mawer        <scm at datlog.co.uk> or < {backbone}!ukc!datlog!scm >
                       Voice:  +44 1 863 0383 (x2153)



More information about the Comp.lang.c mailing list