about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-01-02 21:19:58 -0800
committerEric Wong <normalperson@yhbt.net>2010-01-02 21:19:58 -0800
commite7ac70686b3c09953f6c41966dbd77f77368a9ec (patch)
treeb6d3db1d0f856607d0713fec6229064e2d1ffc2f
parent6f24b5626f89fbb6445c0943ba71f56c8945e18f (diff)
downloadruby_posix_mq-e7ac70686b3c09953f6c41966dbd77f77368a9ec.tar.gz
-rw-r--r--Documentation/posix-mq.rb.1.txt7
-rw-r--r--README36
2 files changed, 43 insertions, 0 deletions
diff --git a/Documentation/posix-mq.rb.1.txt b/Documentation/posix-mq.rb.1.txt
index e9005ee..0cf0bc3 100644
--- a/Documentation/posix-mq.rb.1.txt
+++ b/Documentation/posix-mq.rb.1.txt
@@ -146,8 +146,15 @@ portability.
 Exit status is normally 0.  Exit status is 2 if a timeout occurs, 1 for
 all other errors.
 
+Under FreeBSD, the mq_* system calls are not available unless you load
+the mqueuefs(5) kernel module:
+
+        kldload mqueuefs
+
 # SEE ALSO
 
 * [mq_overview(7)][1]
+* [mqueuefs(5)][2]
 
 [1]: http://kernel.org/doc/man-pages/online/pages/man7/mq_overview.7.html
+[2]: http://freebsd.org/cgi/man.cgi?query=mqueuefs
diff --git a/README b/README
index 91279db..64b6832 100644
--- a/README
+++ b/README
@@ -42,6 +42,42 @@ Unpack it, and run "ruby setup.rb"
 
 Otherwise, via RubyGems: gem install posix_mq
 
+== Usage
+
+The Linux mq_overview(7)
+{manpage}[http://kernel.org/doc/man-pages/online/pages/man7/mq_overview.7.html]
+provides a good overview of programming with POSIX message queues.
+
+Under FreeBSD, you must load the
+{mqueuefs(5)}[http://freebsd.org/cgi/man.cgi?query=mqueuefs]
+kernel module before attempting to use POSIX message queues:
+
+    kldload mqueuefs
+
+Our API matches the C api closely, see the RDoc for full API
+documentation.  Here is an example of a process communicating
+with itself.  In practice, processes that send will be different
+from processes that receive.
+
+    require 'posix_mq'
+    mq = POSIX_MQ.new("/foo", :rw)
+
+    # hello world
+    mq << "hello world"
+    puts mq.receive.first # => should print "hello world"
+
+    # non-blocking operation
+    mq.nonblock = true
+    begin
+      mq.receive
+    rescue Errno::EAGAIN
+    end
+
+    trap(:USR1) { puts mq.receive.first }
+    mq.notify = :USR1
+    mq.send "fire USR1 handler"
+    # "fire USR1 handler" should be printed now
+
 == Development
 
 You can get the latest source via git from the following locations: