summaryrefslogtreecommitdiffstats
path: root/libc/misc/utmp/wtent.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/utmp/wtent.c')
-rw-r--r--libc/misc/utmp/wtent.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libc/misc/utmp/wtent.c b/libc/misc/utmp/wtent.c
index 0378070e7..082e8c184 100644
--- a/libc/misc/utmp/wtent.c
+++ b/libc/misc/utmp/wtent.c
@@ -13,6 +13,10 @@
#include <utmp.h>
#include <fcntl.h>
#include <sys/file.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <errno.h>
+#include <not-cancel.h>
+#endif
#if 0
libc_hidden_proto(memset)
@@ -47,6 +51,16 @@ void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
{
int fd;
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ fd = open_not_cancel(wtmp_file, O_APPEND | O_WRONLY, 0);
+ if (fd >= 0) {
+ if (lockf(fd, F_LOCK, 0)==0) {
+ write_not_cancel(fd, (const char *) lutmp, sizeof(struct utmp));
+ lockf(fd, F_ULOCK, 0);
+ close_not_cancel_no_status(fd);
+ }
+ }
+#else
fd = open(wtmp_file, O_APPEND | O_WRONLY, 0);
if (fd >= 0) {
if (lockf(fd, F_LOCK, 0)==0) {
@@ -55,4 +69,5 @@ void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
close(fd);
}
}
+#endif
}