Skip to content

Instantly share code, notes, and snippets.

@AlainODea
Last active August 29, 2015 14:01
Show Gist options
  • Save AlainODea/0335ac86110e6b9a15d3 to your computer and use it in GitHub Desktop.
Save AlainODea/0335ac86110e6b9a15d3 to your computer and use it in GitHub Desktop.
DTrace EAGAIN returns from read(2)
#!/usr/sbin/dtrace -s
syscall::open:entry
/arg0 != NULL/
{
self->pathptr = arg0;
self->oflag = arg1;
}
syscall::open:return
/self->pathptr != NULL/
{
self->path = copyinstr(self->pathptr);
self->pathptr = 0;
printf("open(%s, %d) = %d (%d)\n",
self->path, self->oflag, arg1, errno);
self->path = 0;
self->oflag = 0;
}
syscall::read:entry
{
self->filedes = arg1;
}
syscall::read:return
/self->filedes != NULL && errno == 11/
{
printf("read(%d, buf) = %d (%d)\n",
self->filedes, arg1, errno);
self->filedes = 0;
ustack();
}
@AlainODea
Copy link
Author

Fix invalid address by guarding against null path in open(2).

Fix dynamic variables dropped by explicitly releasing thread-locals by assigning them to 0 as they are no longer needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment