aboutsummaryrefslogtreecommitdiff
path: root/libXau/AuLock.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-04-08 08:20:47 +0200
committermarha <marha@users.sourceforge.net>2013-04-08 08:20:47 +0200
commita4505330e3469b6956348812ff2d6c24f812a8ba (patch)
treecf2b88c771188580ab585f763d2e7a0309ecab26 /libXau/AuLock.c
parent44fb3db38c5148666f62c78e10fc37bb20ed5c5c (diff)
parent95fb19d661154ba8cfc6c793a0daa25657294b3b (diff)
downloadvcxsrv-a4505330e3469b6956348812ff2d6c24f812a8ba.tar.gz
vcxsrv-a4505330e3469b6956348812ff2d6c24f812a8ba.tar.bz2
vcxsrv-a4505330e3469b6956348812ff2d6c24f812a8ba.zip
Merge remote-tracking branch 'origin/released'
* origin/released: fontconfig libXau mesa xserver xkeyboard-config git update 8 Apr 2013
Diffstat (limited to 'libXau/AuLock.c')
-rw-r--r--libXau/AuLock.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/libXau/AuLock.c b/libXau/AuLock.c
index 7bf9e5d30..5dfc1747e 100644
--- a/libXau/AuLock.c
+++ b/libXau/AuLock.c
@@ -33,15 +33,12 @@ in this Software without prior written authorization from The Open Group.
#include <errno.h>
#include <time.h>
#define Time_t time_t
-#ifndef X_NOT_POSIX
-#include <unistd.h>
-#else
-#ifndef WIN32
-extern unsigned sleep ();
-#else
-#include <X11/Xwindows.h>
-#define link rename
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
#endif
+#ifdef WIN32
+# include <X11/Xwindows.h>
+# define link rename
#endif
int
@@ -58,10 +55,8 @@ long dead)
if (strlen (file_name) > 1022)
return LOCK_ERROR;
- (void) strcpy (creat_name, file_name);
- (void) strcat (creat_name, "-c");
- (void) strcpy (link_name, file_name);
- (void) strcat (link_name, "-l");
+ snprintf (creat_name, sizeof(creat_name), "%s-c", file_name);
+ snprintf (link_name, sizeof(link_name), "%s-l", file_name);
if (stat (creat_name, &statb) != -1) {
now = time ((Time_t *) 0);
/*
@@ -69,8 +64,8 @@ long dead)
* case a 0 deadtime to force lock removal
*/
if (dead == 0 || now - statb.st_ctime > dead) {
- (void) unlink (creat_name);
- (void) unlink (link_name);
+ (void) remove (creat_name);
+ (void) remove (link_name);
}
}
@@ -84,7 +79,7 @@ long dead)
(void) close (creat_fd);
}
if (creat_fd != -1) {
-#ifndef X_NOT_POSIX
+#ifdef HAVE_PATHCONF
/* The file system may not support hard links, and pathconf should tell us that. */
if (1 == pathconf(creat_name, _PC_LINK_MAX)) {
if (-1 == rename(creat_name, link_name)) {
@@ -93,8 +88,9 @@ long dead)
} else {
return LOCK_SUCCESS;
}
- } else {
+ } else
#endif
+ {
if (link (creat_name, link_name) != -1)
return LOCK_SUCCESS;
if (errno == ENOENT) {
@@ -103,9 +99,7 @@ long dead)
}
if (errno != EEXIST)
return LOCK_ERROR;
-#ifndef X_NOT_POSIX
}
-#endif
}
(void) sleep ((unsigned) timeout);
--retries;