}
waitpid(pid, &status, 0);
- return WEXITSTATUS(status);
+ return WIFEXITED(status) ? WEXITSTATUS(status) : -1;
}
#else
int usign_s(const char *msgfile, const char *seckeyfile, const char *sigfile, bool quiet) {
close(fds[1]);
waitpid(pid, &status, 0);
- status = WEXITSTATUS(status);
- if (fingerprint && !WEXITSTATUS(status)) {
+ status = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
+
+ if (fingerprint && !status) {
ssize_t r;
memset(fingerprint, 0, 17);
r = read(fds[0], fingerprint, 17);
}
waitpid(pid, &status, 0);
- return WEXITSTATUS(status);
+ return WIFEXITED(status) ? WEXITSTATUS(status) : -1;
}