Skip to content

Commit 884bd36

Browse files
committed
kevent64 shim turns time negative in absolute to relative conversion. Checked for it
1 parent e48115b commit 884bd36

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/shims/linux_stubs.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,14 @@ int kevent64(int kq, /*const*/ struct kevent64_s *changelist, int nchanges, stru
158158
// into a relative. Consider fiddling with creating relative events instead (didn't work
159159
// on first attempt). We also ignore the LEEWAY. Finally we must convert from
160160
// NSECS to MSECS (might have to expand to deal with OTHER NOTE_xSECS flags
161-
changelist->data -= time(NULL) * NSEC_PER_SEC;
162-
changelist->data /= 1000000;
161+
162+
changelist->data -= _dispatch_get_nanoseconds();
163+
//changelist->data -= time(NULL) * NSEC_PER_SEC;
163164
dbg_kevent64("kevent64(%s,%x) data=%lx:%ld\n",
164165
_evfiltstr(changelist->filter),changelist->fflags,
165166
changelist->data,changelist->data);
167+
changelist->data /= 1000000UL;
168+
if ((int64_t)(changelist->data) <= 0) changelist->data = 1; // for some reason time turns negative
166169
}
167170
}
168171
#endif

0 commit comments

Comments
 (0)