Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 78b5e16d1b

Fetching latest commit…

Cannot retrieve the latest commit at this time

README
This directory contains two zloop examples:


zloop-sysfs:
------------
Example monitoring a sysfs device through a file descriptor zmq_pollitem.


sysfsexample kernel module:
---------------------------
this creates two sysfs entries:
- /sys/syfs_example/notify
- /sys/syfs_example/trigger

to activate:

$ insmod ./sysfsexample.ko

Verify with dmesg that it has been properly loaded.

An int value written to /sys/syfs_example/trigger will be returned by
reading /sys/syfs_example/notify; also a sysfs_notify() is executed on
/sys/syfs_example/notify to signal to a user process that new content is available.

then start zloop-sysfs like so:

$ zloop-sysfs /sys/sysfs_example/notify

then try a few times
# echo 123 > /sys/syfs_example/trigger

this will cause a sysfs_notify() on /sys/sysfs_example/notify; note that only
the first echo will cause zloop-sysfs to react since the handler is disabled
by czmq as a reaction to the POLLERR delivered by the sysfs event.

To demonstrate the ZMQ_IGNERR patch, try like so:


$ zloop-sysfs /sys/sysfs_example/notify 1

# NB: the extra argument will activate the ZMQ_IGNERR option

now try again a few times, which should work fine:
# echo 123 > /sys/syfs_example/trigger

The handler will not be disabled any more.


zloop-namedpipe:
------------
Example monitoring a named pipe device through a file descriptor zmq_pollitem.
This has nothing to do with the ZMQ_IGNERR patch per se - it just demonstrates handling
reading, and dealing with a closed named pipe which is a bit tricky.

To try:

$ mknod /tmp/pipe p
$ zloop-namedpip /tmp/pipe
Something went wrong with that request. Please try again.