Correctly close the pipe used for scriptlet execution

We never had a call to pclose() in here before, leaving our file descriptor
in some sort of limbo state. In addition, clean up some of the other logic
such as directly calling exit(1) on a popen() failure rather than going to
our cleanup block, and handling and respecting the exit status of the
subprocess correctly.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2008-10-18 22:46:27 -05:00
parent d24592cbcd
commit d1fec15d81
1 changed files with 3 additions and 3 deletions

View File

@ -560,8 +560,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
if(!pipe) {
_alpm_log(PM_LOG_ERROR, _("call to popen failed (%s)"),
strerror(errno));
retval = 1;
goto cleanup;
exit(1);
}
while(!feof(pipe)) {
char line[PATH_MAX];
@ -570,7 +569,8 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
alpm_logaction("%s", line);
EVENT(trans, PM_TRANS_EVT_SCRIPTLET_INFO, line, NULL);
}
exit(0);
retval = pclose(pipe);
exit(WEXITSTATUS(retval));
} else {
/* this code runs for the parent only (wait on the child) */
pid_t retpid;