Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

C's system() & COMMAND.COM (Developers)

posted by alexfru(R), USA, 13.09.2014, 01:05

> I looked up the system() function in my copy of K&R 2nd edition, and it
> says
> "In the UNIX system, the status return is the value returned by exit"
> Further it says "the return value is implementation-dependent".

Check out some more modern stuff.

If command is not a null pointer, system() shall return the termination status of the command language interpreter in the format specified by waitpid(). The termination status shall be as defined for the sh utility; ...

The value stored at the location pointed to by stat_loc shall be 0 if and only if the status returned is from a terminated child process that terminated by one of the following means:

The process returned 0 from main().

The process called _exit() or exit() with a status argument of 0.

The process was terminated because the last thread in the process terminated.

The following exit values shall be returned:

The script to be executed consisted solely of zero or more blank lines or comments, or both.
A non-interactive shell detected a syntax, redirection, or variable assignment error.
A specified command_file could not be found by a non-interactive shell.

Otherwise, the shell shall return the exit status of the last command it invoked or attempted to invoke...

I can reasonably expect to get 0 from system() on POSIX systems if the command has succeeded (main() returned with 0) and non-zero otherwise.



Complete thread:

Back to the forum
Board view  Mix view
15297 Postings in 1378 Threads, 254 registered users, 20 users online (0 registered, 20 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum