From f9be2334f7b01ba30235500cb12d4ed61fff564b Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 10 Sep 2008 14:29:50 -0500 Subject: 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 --- lib/libalpm/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/libalpm/util.c') diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index b26c9702..da3463b0 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -254,7 +254,8 @@ int _alpm_lckmk() _alpm_makepath(dir); FREE(dir); - fd = open(file, O_WRONLY | O_CREAT | O_EXCL, 0000); + while((fd = open(file, O_WRONLY | O_CREAT | O_EXCL, 0000)) == -1 + && errno == EINTR); return(fd > 0 ? fd : -1); } -- cgit v1.2.3-54-g00ecf