First, system returns either -1 for error, in which case, as is generally 
true, you need to look at errno to find the reason for the failure; 
otherwise it returns the exit code of the application.

Second, it's often useful to use truss to diagnose errors like this:  Try 
truss -t execve -a <command> and see exactly what arguments the shell is 
getting.

Are you supplying a full absolute path in dest, or is it relative?

mspaper wrote:
> rm and cp return non zero values sometimes.
> 
> sprintf(tmp, "rm -rf %s/* 2>/dev/null\n", dest);
> rc = system( tmp );
> rc = 1 
> 
> sprintf(tmp, "cp -r %s/* %s 2>/dev/null", source, dest);
> rc = system( tmp );
> rc = -1 
> 
> The files exist and the paths are correct. I can do a manual copy but the 
> application fails. If I restart the application, this works fine. 
> Can anyone tell why this could happen? What do the return values mean?
>  
>  
> This message posted from opensolaris.org
> _______________________________________________
> opensolaris-code mailing list
> opensolaris-code@opensolaris.org
> http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to