sco unix 5.0.5 call sytem() function question!please help me!

i want to know the return value of calling system function in the sco unix 5.0.5.what is the meaning of the return value?
............
int ret;
char cmd[128];
strcpy(cmd,"compress -F -c file >file.Z");
ret = system(cmd);
.............
i want to know how to judge whether the file's compress is success due to the ret value;
please help me! thanks

"system" on failure normally returns "-1" i.e if either fork, exec or waitpid which are internally called "System" fail.

Rather than checking for the return value, you can check the value set in the system defined global variable "errno" after executing "system". the value of errno can let you know the staus after execution of "system"

Be sure to include the file "errno.h" .

But even "errno" is not full proof.

I think others would certainly have better ideas..

thanks for your advice,but it is not right through judging the errno values,
example:
#include <stdio.h>
#include <errno.h>
main()
{
int ret;
char cmd[128];
strcpy(cmd,"compress /tmp/lll");

    ret = system\(cmd\);
    printf\("after system errno[%d], ret[%d]\\n", errno, ret\);
    exit\(0\);

}
if the file��/tmp/lll�� doesnot exist,execute this program,screen will
output:
compress: could not read /tmp/lll: No such file or directory (error 2)
after system errno[0], ret[256]
errno only represents the result of calling system function,not the result of the command (compress).

#include <stdio.h>
#include <errno.h>
main()
{
int ret;
char cmd[128];
strcpy(cmd,"compress /tmp/lll");

    ret = system\(cmd\);
    /* add this sentence"/
    ret &gt;&gt;= 8
    printf\("after system errno[%d], ret[%d]\\n", errno, ret\);
    if \( ret == 0 \) 
         printf\("compress success\\n"\);
    else 
         printf\("compress failure\\n"\);
    exit\(0\);

}

is it right to judge whether the file compress is success though the ret >>= 8;

well, it makes sense to see the value of of both "ret" and "errno". But how did u get this magic number of 8 ??

"ret >>=8"

Its better to check that the value of ret is 0. Even values greater than zero denote an error.

The status of a child process may be interpreted using the following macros, which are defined in <sys/wait.h> :
WIFEXITED(status)
WEXITSTATUS(status)
and others. Here the status is the integer value returned by the system function.
Example :
ret = WEXITSTATUS ( system ( "command > /dev/null " ) ) ;
a value 0 always means success.