summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/trans.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2008-09-10 21:29:50 +0200
committerDan McGee <dan@archlinux.org>2008-10-13 04:28:05 +0200
commitf9be2334f7b01ba30235500cb12d4ed61fff564b (patch)
tree796b90d94985d8e0ad19f3c05d7f19dd275bc387 /lib/libalpm/trans.c
parent18452a6c51827e91f37978397552c30cb92c26cd (diff)
downloadpacman-f9be2334f7b01ba30235500cb12d4ed61fff564b.tar.gz
pacman-f9be2334f7b01ba30235500cb12d4ed61fff564b.tar.xz
libalpm: handle syscall interruption correctly
It is possible to throw EINTR from a system call such as open(), close(), or waitpid() if custom signal handlers are set up and they are not initialized with the SA_RESTART flag. This was noticed by Andreas Radke when ^C (SIGINT) was given during the call to waitpid(), causing it to throw the EINTR error and we could not accommodate it. Simply wrap these calls in a simple loop that allows us to retry the call if interrupted. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/trans.c')
-rw-r--r--lib/libalpm/trans.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index d6b165d3..f996c02c 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -30,7 +30,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
-#include <unistd.h>
#include <errno.h>
/* libalpm */
@@ -205,7 +204,7 @@ int SYMEXPORT alpm_trans_release()
/* unlock db */
if(handle->lckfd != -1) {
- close(handle->lckfd);
+ while(close(handle->lckfd) == -1 && errno == EINTR);
handle->lckfd = -1;
}
if(_alpm_lckrm()) {
@@ -576,7 +575,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
/* this code runs for the parent only (wait on the child) */
pid_t retpid;
int status;
- retpid = waitpid(pid, &status, 0);
+ while((retpid = waitpid(pid, &status, 0)) == -1 && errno == EINTR);
if(retpid == -1) {
_alpm_log(PM_LOG_ERROR, _("call to waitpid failed (%s)\n"),
strerror(errno));