diff --git a/ChangeLog b/ChangeLog index ae78aea9f5..668bee3d3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Mar 25 23:26:02 2003 Yukihiro Matsumoto + + * signal.c (trap): return "DEFAULT" and "IGNORE" respectively for + previous sighandler SIG_DFL and SIG_IGN. [ruby-talk:67860] + Tue Mar 25 12:24:15 2003 Yukihiro Matsumoto * eval.c (rb_yield_0): call avalue_to_mrhs() to assign block diff --git a/sample/test.rb b/sample/test.rb index 247518c75e..fb7c0f6757 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -248,6 +248,11 @@ f = lambda {|r,*l| test_ok([] == r); test_ok([1] == l)} f.call([], *[1]) f.yield([], *[1]) +a = [42,55] +lambda{|x| test_ok([42,55] == x)}.call(a) +lambda{|x,| test_ok([42,55] == x)}.call(a) +lambda{|*x| test_ok([[42,55]] == x)}.call(a) + a,=*[1] test_ok(a == 1) diff --git a/signal.c b/signal.c index 16c47a7f7d..3477abb0f5 100644 --- a/signal.c +++ b/signal.c @@ -481,8 +481,8 @@ static VALUE trap(arg) struct trap_arg *arg; { - sighandler_t func; - VALUE command, old; + sighandler_t func, oldfunc; + VALUE command, oldcmd; int sig = -1; char *s; @@ -588,9 +588,13 @@ trap(arg) #endif } } - ruby_signal(sig, func); - old = trap_list[sig]; - if (!old) old = Qnil; + oldfunc = ruby_signal(sig, func); + oldcmd = trap_list[sig]; + if (!oldcmd) { + if (oldfunc == SIG_IGN) oldcmd = rb_str_new2("IGNORE"); + else if (oldfunc == sighandler) oldcmd = rb_str_new2("DEFAULT"); + else oldcmd = Qnil; + } trap_list[sig] = command; /* enable at least specified signal. */ @@ -601,7 +605,7 @@ trap(arg) arg->mask &= ~sigmask(sig); #endif #endif - return old; + return oldcmd; } #ifndef _WIN32