- Its callers only care about success vs failure, so only ever return
0 or -1 and take waitpid() errors into account too. As a side effect
shuts up a set-but-unused compiler warning too
* Copy data from URL to local file.
* @param url url string of source
* @param dest file name of destination
- * @return 0 on success, otherwise FTPERR_* code
+ * @return 0 on success, -1 on error
*/
int urlGetFile(const char * url, const char * dest);
char *cmd = NULL;
const char *target = NULL;
char *urlhelper = NULL;
- int rc;
- pid_t pid, wait;
+ int status;
+ pid_t pid;
urlhelper = rpmExpand("%{?_urlhelper}", NULL);
execvp(argv[0], argv);
exit(127); /* exit with 127 for compatibility with bash(1) */
}
- wait = waitpid(pid, &rc, 0);
- cmd = _free(cmd);
-
- return rc;
+ free(cmd);
+ return ((waitpid(pid, &status, 0) != -1) &&
+ WIFEXITED(status) && (WEXITSTATUS(status) == 0)) ? 0 : -1;
}