summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-03-25 15:25:18 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-03-25 15:25:18 +0000
commit80a97f173f109364b5457b45f53c6d91102c242f (patch)
treee5c75ec3d25a02e65af59a480ac9bc181eb612ff /signal.c
parentcd6f64e37cba29badce8260a68747b54fc6a5f9e (diff)
* signal.c (trap): return "DEFAULT" and "IGNORE" respectively for
previous sighandler SIG_DFL and SIG_IGN. [ruby-talk:67860] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/signal.c b/signal.c
index 16c47a7..3477abb 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