Permalink
Browse files

updating rdoc, removing binfile

  • Loading branch information...
tenderlove committed Aug 11, 2009
1 parent f758844 commit d943f41a503d189af075a4e8095ee20fc485fa52
Showing with 51 additions and 17 deletions.
  1. +0 −1 Manifest.txt
  2. +32 −7 README.rdoc
  3. +1 −0 Rakefile
  4. +0 −3 bin/never_say_die
  5. +17 −2 ext/neversaydie/neversaydie.c
  6. +0 −3 lib/never_say_die.rb
  7. +1 −1 test/test_never_say_die.rb
View
@@ -3,7 +3,6 @@ CHANGELOG.rdoc
Manifest.txt
README.rdoc
Rakefile
-bin/never_say_die
ext/neversaydie/extconf.rb
ext/neversaydie/neversaydie.c
lib/neversaydie.rb
View
@@ -1,32 +1,57 @@
= never_say_die
-* FIX (url)
+* http://seattlerb.rubyforge.org
+* http://github.com/tenderlove/neversaydie
== DESCRIPTION:
-FIX (describe your package)
+NEVER SAY DIE lets you rescue from segmentation faults. Got a SEGV, don't
+worry about it anymore! Just rescue an exception and get on with life.
== FEATURES/PROBLEMS:
-* FIX (list of features or problems)
+* Oh so many problems...
+* Portability...
+* Not solving the root cause..
+* Just to name a few
== SYNOPSIS:
- FIX (code sample of usage)
+I will let the (passing) test speak for itself:
+
+ assert_raises NeverSayDie do
+ NeverSayDie.segv
+ end
+
+Here is the source of the segv method:
+
+ static VALUE segv(VALUE self)
+ {
+ int *ptr = NULL;
+ *ptr = 1;
+
+ return self;
+ }
== REQUIREMENTS:
-* FIX (list of requirements)
+* libsigsegv
== INSTALL:
-* FIX (sudo gem install, anything else)
+First, install libsigsegv. If you're on OS X, do this:
+
+ $ sudo port install libsigsegv
+
+I'm not sure about other platforms. Then install the gem:
+
+ $ sudo gem install neversaydie
== LICENSE:
(The MIT License)
-Copyright (c) 2009 FIX
+Copyright (c) 2009 Aaron Patterson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
@@ -11,6 +11,7 @@ HOE = Hoe.spec name do
self.readme_file = 'README.rdoc'
self.history_file = 'CHANGELOG.rdoc'
self.extra_rdoc_files = FileList['*.rdoc']
+ spec_extras[:extensions] = "ext/nokogiri/extconf.rb"
end
RET = Rake::ExtensionTask.new(name, HOE.spec) do |ext|
View
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-
-abort "you need to write me"
@@ -10,8 +10,23 @@ static VALUE segv(VALUE self)
return self;
}
+VALUE cNeverSayDie;
+
+void continuation(void * a, void * b, void * c)
+{
+ rb_raise(cNeverSayDie, "segfault at %ld", (int)a);
+}
+
+int handler(void * fault_address, int serious)
+{
+ sigsegv_leave_handler(&continuation, fault_address, NULL, NULL);
+ return 1;
+}
+
void Init_neversaydie()
{
- VALUE klass = rb_define_class("NeverSayDie", rb_eRuntimeError);
- rb_define_singleton_method(klass, "segv", segv, 0);
+ cNeverSayDie = rb_define_class("NeverSayDie", rb_eRuntimeError);
+ rb_define_singleton_method(cNeverSayDie, "segv", segv, 0);
+
+ sigsegv_install_handler(&handler);
}
View
@@ -1,3 +0,0 @@
-class NeverSayDie
- VERSION = '1.0.0'
-end
@@ -2,7 +2,7 @@
require "neversaydie"
class TestNeverSayDie < Test::Unit::TestCase
- def test_called
+ def test_recovers
assert_raises NeverSayDie do
NeverSayDie.segv
end

0 comments on commit d943f41

Please sign in to comment.