summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/sys/kqueue.242
-rw-r--r--lib/libkvm/kvm_amd64.c1
-rw-r--r--lib/libkvm/kvm_proc.c15
-rw-r--r--lib/libthr/thread/thr_resume_np.c2
-rw-r--r--lib/libthr/thread/thr_sig.c4
5 files changed, 48 insertions, 16 deletions
diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2
index b692c1f..2856a3f 100644
--- a/lib/libc/sys/kqueue.2
+++ b/lib/libc/sys/kqueue.2
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 1, 2016
+.Dd May 3, 2016
.Dt KQUEUE 2
.Os
.Sh NAME
@@ -359,30 +359,54 @@ Takes a file descriptor as the identifier and the events to watch for in
.Va fflags ,
and returns when one or more of the requested events occurs on the descriptor.
The events to monitor are:
-.Bl -tag -width "Dv NOTE_RENAME"
+.Bl -tag -width "Dv NOTE_CLOSE_WRITE"
+.It Dv NOTE_ATTRIB
+The file referenced by the descriptor had its attributes changed.
+.It Dv NOTE_CLOSE
+A file descriptor referencing the monitored file, was closed.
+The closed file descriptor did not have write access.
+.It Dv NOTE_CLOSE_WRITE
+A file descriptor referencing the monitored file, was closed.
+The closed file descriptor has write access.
+.Pp
+This note, as well as
+.Dv NOTE_CLOSE ,
+are not activated when files are closed forcibly by
+.Xr unmount 2 or
+.Xr revoke 2 .
+Instead,
+.Dv NOTE_REVOKE
+is sent for such events.
.It Dv NOTE_DELETE
The
.Fn unlink
-system call
-was called on the file referenced by the descriptor.
-.It Dv NOTE_WRITE
-A write occurred on the file referenced by the descriptor.
+system call was called on the file referenced by the descriptor.
.It Dv NOTE_EXTEND
-The file referenced by the descriptor was extended.
-.It Dv NOTE_ATTRIB
-The file referenced by the descriptor had its attributes changed.
+For regular file, the file referenced by the descriptor was extended.
+.Pp
+For directory, reports that a directory entry was added or removed,
+as the result of rename operation.
+The
+.Dv NOTE_EXTEND
+event is not reported when a name is changed inside the directory.
.It Dv NOTE_LINK
The link count on the file changed.
In particular, the
.Dv NOTE_LINK
event is reported if a subdirectory was created or deleted inside
the directory referenced by the descriptor.
+.It Dv NOTE_OPEN
+The file referenced by the descriptor was opened.
+.It Dv NOTE_READ
+A read occurred on the file referenced by the descriptor.
.It Dv NOTE_RENAME
The file referenced by the descriptor was renamed.
.It Dv NOTE_REVOKE
Access to the file was revoked via
.Xr revoke 2
or the underlying file system was unmounted.
+.It Dv NOTE_WRITE
+A write occurred on the file referenced by the descriptor.
.El
.Pp
On return,
diff --git a/lib/libkvm/kvm_amd64.c b/lib/libkvm/kvm_amd64.c
index 65d697c..b64ea77 100644
--- a/lib/libkvm/kvm_amd64.c
+++ b/lib/libkvm/kvm_amd64.c
@@ -200,6 +200,7 @@ _kvm_initvtop(kvm_t *kd)
PML4 = _kvm_malloc(kd, PAGE_SIZE);
if (kvm_read(kd, pa, PML4, PAGE_SIZE) != PAGE_SIZE) {
_kvm_err(kd, kd->program, "cannot read KPML4phys");
+ free(PML4);
return (-1);
}
kd->vmst->PML4 = PML4;
diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c
index 31258d7..f8e152e 100644
--- a/lib/libkvm/kvm_proc.c
+++ b/lib/libkvm/kvm_proc.c
@@ -642,6 +642,7 @@ kvm_argv(kvm_t *kd, const struct kinfo_proc *kp, int env, int nchr)
static char *buf, *p;
static char **bufp;
static int argc;
+ char **nbufp;
if (!ISALIVE(kd)) {
_kvm_err(kd, kd->program,
@@ -657,9 +658,15 @@ kvm_argv(kvm_t *kd, const struct kinfo_proc *kp, int env, int nchr)
_kvm_err(kd, kd->program, "cannot allocate memory");
return (0);
}
- buflen = nchr;
argc = 32;
bufp = malloc(sizeof(char *) * argc);
+ if (bufp == NULL) {
+ free(buf);
+ buf = NULL;
+ _kvm_err(kd, kd->program, "cannot allocate memory");
+ return (NULL);
+ }
+ buflen = nchr;
} else if (nchr > buflen) {
p = realloc(buf, nchr);
if (p != NULL) {
@@ -693,8 +700,10 @@ kvm_argv(kvm_t *kd, const struct kinfo_proc *kp, int env, int nchr)
p += strlen(p) + 1;
if (i >= argc) {
argc += argc;
- bufp = realloc(bufp,
- sizeof(char *) * argc);
+ nbufp = realloc(bufp, sizeof(char *) * argc);
+ if (nbufp == NULL)
+ return (NULL);
+ bufp = nbufp;
}
} while (p < buf + bufsz);
bufp[i++] = 0;
diff --git a/lib/libthr/thread/thr_resume_np.c b/lib/libthr/thread/thr_resume_np.c
index 53377da..212d1c8 100644
--- a/lib/libthr/thread/thr_resume_np.c
+++ b/lib/libthr/thread/thr_resume_np.c
@@ -90,7 +90,7 @@ static void
resume_common(struct pthread *thread)
{
/* Clear the suspend flag: */
- thread->flags &= ~THR_FLAGS_NEED_SUSPEND;
+ thread->flags &= ~(THR_FLAGS_NEED_SUSPEND | THR_FLAGS_SUSPENDED);
thread->cycle++;
_thr_umtx_wake(&thread->cycle, 1, 0);
}
diff --git a/lib/libthr/thread/thr_sig.c b/lib/libthr/thread/thr_sig.c
index ebb6c58..dc51f34 100644
--- a/lib/libthr/thread/thr_sig.c
+++ b/lib/libthr/thread/thr_sig.c
@@ -373,8 +373,7 @@ check_suspend(struct pthread *curthread)
*/
curthread->critical_count++;
THR_UMUTEX_LOCK(curthread, &(curthread)->lock);
- while ((curthread->flags & (THR_FLAGS_NEED_SUSPEND |
- THR_FLAGS_SUSPENDED)) == THR_FLAGS_NEED_SUSPEND) {
+ while ((curthread->flags & THR_FLAGS_NEED_SUSPEND) != 0) {
curthread->cycle++;
cycle = curthread->cycle;
@@ -391,7 +390,6 @@ check_suspend(struct pthread *curthread)
THR_UMUTEX_UNLOCK(curthread, &(curthread)->lock);
_thr_umtx_wait_uint(&curthread->cycle, cycle, NULL, 0);
THR_UMUTEX_LOCK(curthread, &(curthread)->lock);
- curthread->flags &= ~THR_FLAGS_SUSPENDED;
}
THR_UMUTEX_UNLOCK(curthread, &(curthread)->lock);
curthread->critical_count--;
OpenPOWER on IntegriCloud