Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/handle.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-09-19 14:08:14 -0500
committerDan McGee <dan@archlinux.org>2011-09-19 14:11:08 -0500
commit288a81d8470b1fd2e8a8f0814abe4cbfed71497c (patch)
tree36f9c2ef8575926161315d5057504d00bdeac139 /lib/libalpm/handle.c
parentbfe36c2ddf869e2ebc44bec1e35c0319263ac386 (diff)
Use more efficient way of restoring working directory
Rather than using a string-based path, we can restore the working directory via a file descriptor and use of fchdir(). From the getcwd manpage: Opening the current directory (".") and calling fchdir(2) to return is usually a faster and more reliable alternative when sufficiently many file descriptors are available. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/handle.c')
-rw-r--r--lib/libalpm/handle.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 5fb4f2bb..dcd81cea 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -115,7 +115,7 @@ int _alpm_handle_lock(alpm_handle_t *handle)
do {
fd = open(handle->lockfile, O_WRONLY | O_CREAT | O_EXCL, 0000);
} while(fd == -1 && errno == EINTR);
- if(fd > 0) {
+ if(fd >= 0) {
FILE *f = fdopen(fd, "w");
fprintf(f, "%ld\n", (long)getpid());
fflush(f);