Can someone please point me to some nontrivial examples of
how to use the Ruby syscall function effectively?

For example, 

. How do you handle cases where the syscall writes a return value
  into a C language struct (eg., getrusage)?

. How do you obtain system call numbers in a portable way?
  For example, how do I write Ruby code that obtain the system
  call number for SYS_getrusage?  Note that it is not in general
  possible to grep the /usr/include/syscall.h function because
  the system call numbers are not always in that file.

Thanks,
Eric