From 288a81d8470b1fd2e8a8f0814abe4cbfed71497c Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 19 Sep 2011 14:08:14 -0500 Subject: 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 --- lib/libalpm/handle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libalpm/handle.c') 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); -- cgit v1.2.3-54-g00ecf