[Xastir-Dev] Snapshot problem
Derrick J Brashear
shadow at dementia.org
Sat Jun 7 11:47:01 EDT 2003
Curt said:
> if ( system( command ) != 0 ) {
> // We _may_ have had an error. Check errno to make
> // sure.
> if (errno) {
> fprintf(stderr, "%s\n", strerror(errno));
> fprintf(stderr,
> "Failed to convert snapshot: %s -> %s\n",
> xpm_filename,
> png_filename);
> }
> }
>
>
> I did not see the "Failed to convert snapshot" message. This means
> that ImageMagick's convert didn't return an error code in "errno"?
> Is ImageMagick not playing by the rules (again)? I guess I'll add
> yet another error message to see if the system call is returning
> with an error.
No, that's legit. errno is set if system() fails, not if the command you
run returns non-zero.
>From system(3):
The value returned is -1 on error (e.g. fork failed), and
the return status of the command otherwise. This latter
return status is in the format specified in wait(2).
Thus, the exit code of the command will be WEXITSTA
TUS(status). In case /bin/sh could not be executed, the
exit status will be that of a command that does exit(127).
So expect -1 and check errno, or greater than 0 and use WEXITSTATUS
(except on pre-posix systems but that's another story)
More information about the Xastir-dev
mailing list