mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* signal.c (sigexit): call rb_thread_signal_exit() instead of
rb_exit(). [ruby-dev:26347] * eval.c (rb_thread_signal_exit): a new function to exit on main thread. * eval.c (rb_thread_switch): exit status should be retrieved from ruby_errinfo. * eval.c (rb_f_exit): ensure exit(0) should call exit(EXIT_SUCCESS). * missing/mkdir.c: remove. [ruby-core:05177] * lib/delegate.rb (SimpleDelegator::__setobj__): need check for recursive delegation. [ruby-core:04940] * misc/ruby-mode.el (ruby-expr-beg): fix looking point drift. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aeaad8feab
commit
f87aa95e94
9 changed files with 70 additions and 116 deletions
27
ChangeLog
27
ChangeLog
|
@ -1,3 +1,21 @@
|
||||||
|
Mon Jun 13 01:54:20 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* signal.c (sigexit): call rb_thread_signal_exit() instead of
|
||||||
|
rb_exit(). [ruby-dev:26347]
|
||||||
|
|
||||||
|
* eval.c (rb_thread_signal_exit): a new function to exit on main
|
||||||
|
thread.
|
||||||
|
|
||||||
|
* eval.c (rb_thread_switch): exit status should be retrieved from
|
||||||
|
ruby_errinfo.
|
||||||
|
|
||||||
|
* eval.c (rb_f_exit): ensure exit(0) should call
|
||||||
|
exit(EXIT_SUCCESS).
|
||||||
|
|
||||||
|
Fri Jun 10 23:35:34 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* missing/mkdir.c: remove. [ruby-core:05177]
|
||||||
|
|
||||||
Fri Jun 10 22:54:26 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Jun 10 22:54:26 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* missing.h: fd_set stuffs need sys/types.h. fixed: [ruby-core:05179]
|
* missing.h: fd_set stuffs need sys/types.h. fixed: [ruby-core:05179]
|
||||||
|
@ -22,6 +40,15 @@ Thu Jun 9 19:55:41 2005 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
* gc.c (Init_stack): remove IA64_MAGIC_STACK_LIMIT.
|
* gc.c (Init_stack): remove IA64_MAGIC_STACK_LIMIT.
|
||||||
|
|
||||||
|
Thu Jun 9 11:55:34 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/delegate.rb (SimpleDelegator::__setobj__): need check for
|
||||||
|
recursive delegation. [ruby-core:04940]
|
||||||
|
|
||||||
|
Wed Jun 8 18:47:10 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* misc/ruby-mode.el (ruby-expr-beg): fix looking point drift.
|
||||||
|
|
||||||
Wed Jun 8 11:11:34 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Wed Jun 8 11:11:34 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* bignum.c (get2comp): calculate proper 2's complement for
|
* bignum.c (get2comp): calculate proper 2's complement for
|
||||||
|
|
|
@ -423,7 +423,7 @@ AC_FUNC_ALLOCA
|
||||||
AC_FUNC_MEMCMP
|
AC_FUNC_MEMCMP
|
||||||
AC_FUNC_FSEEKO
|
AC_FUNC_FSEEKO
|
||||||
AC_CHECK_FUNCS(ftello)
|
AC_CHECK_FUNCS(ftello)
|
||||||
AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
|
AC_REPLACE_FUNCS(dup2 memmove strcasecmp strncasecmp strerror strftime\
|
||||||
strchr strstr strtoul crypt flock vsnprintf\
|
strchr strstr strtoul crypt flock vsnprintf\
|
||||||
isnan finite isinf hypot acosh erf)
|
isnan finite isinf hypot acosh erf)
|
||||||
AC_CHECK_FUNCS(fmod killpg wait4 waitpid syscall chroot fsync getcwd\
|
AC_CHECK_FUNCS(fmod killpg wait4 waitpid syscall chroot fsync getcwd\
|
||||||
|
|
39
eval.c
39
eval.c
|
@ -1353,6 +1353,14 @@ static int thread_reset_raised();
|
||||||
static VALUE exception_error;
|
static VALUE exception_error;
|
||||||
static VALUE sysstack_error;
|
static VALUE sysstack_error;
|
||||||
|
|
||||||
|
static int
|
||||||
|
sysexit_status(err)
|
||||||
|
VALUE err;
|
||||||
|
{
|
||||||
|
VALUE st = rb_iv_get(err, "status");
|
||||||
|
return NUM2INT(st);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
error_handle(ex)
|
error_handle(ex)
|
||||||
int ex;
|
int ex;
|
||||||
|
@ -1399,8 +1407,7 @@ error_handle(ex)
|
||||||
case TAG_RAISE:
|
case TAG_RAISE:
|
||||||
case TAG_FATAL:
|
case TAG_FATAL:
|
||||||
if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
|
if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
|
||||||
VALUE st = rb_iv_get(ruby_errinfo, "status");
|
status = sysexit_status(ruby_errinfo);
|
||||||
status = NUM2INT(st);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error_print();
|
error_print();
|
||||||
|
@ -4334,6 +4341,9 @@ rb_f_exit(argc, argv)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
istatus = NUM2INT(status);
|
istatus = NUM2INT(status);
|
||||||
|
#if EXIT_SUCCESS != 0
|
||||||
|
if (istatus == 0) istatus = EXIT_SUCCESS;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10021,8 +10031,7 @@ rb_thread_switch(n)
|
||||||
case RESTORE_EXIT:
|
case RESTORE_EXIT:
|
||||||
ruby_errinfo = th_raise_exception;
|
ruby_errinfo = th_raise_exception;
|
||||||
ruby_current_node = th_raise_node;
|
ruby_current_node = th_raise_node;
|
||||||
error_print();
|
terminate_process(sysexit_status(ruby_errinfo), 0, 0);
|
||||||
terminate_process(EXIT_FAILURE, 0, 0);
|
|
||||||
break;
|
break;
|
||||||
case RESTORE_NORMAL:
|
case RESTORE_NORMAL:
|
||||||
default:
|
default:
|
||||||
|
@ -11970,6 +11979,28 @@ rb_thread_trap_eval(cmd, sig, safe)
|
||||||
rb_thread_restore_context(curr_thread, RESTORE_TRAP);
|
rb_thread_restore_context(curr_thread, RESTORE_TRAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rb_thread_signal_exit()
|
||||||
|
{
|
||||||
|
VALUE args[2];
|
||||||
|
|
||||||
|
rb_thread_critical = 0;
|
||||||
|
if (curr_thread == main_thread) {
|
||||||
|
rb_thread_ready(curr_thread);
|
||||||
|
rb_exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
args[0] = INT2NUM(EXIT_SUCCESS);
|
||||||
|
args[1] = rb_str_new2("exit");
|
||||||
|
rb_thread_ready(main_thread);
|
||||||
|
if (!rb_thread_dead(curr_thread)) {
|
||||||
|
if (THREAD_SAVE_CONTEXT(curr_thread)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rb_thread_main_jump(rb_class_new_instance(2, args, rb_eSystemExit),
|
||||||
|
RESTORE_EXIT);
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_thread_raise(argc, argv, th)
|
rb_thread_raise(argc, argv, th)
|
||||||
int argc;
|
int argc;
|
||||||
|
|
1
intern.h
1
intern.h
|
@ -210,6 +210,7 @@ VALUE rb_thread_create _((VALUE (*)(ANYARGS), void*));
|
||||||
void rb_thread_interrupt _((void));
|
void rb_thread_interrupt _((void));
|
||||||
void rb_thread_trap_eval _((VALUE, int, int));
|
void rb_thread_trap_eval _((VALUE, int, int));
|
||||||
void rb_thread_signal_raise _((char*));
|
void rb_thread_signal_raise _((char*));
|
||||||
|
void rb_thread_signal_exit _((void));
|
||||||
int rb_thread_select _((int, fd_set *, fd_set *, fd_set *, struct timeval *));
|
int rb_thread_select _((int, fd_set *, fd_set *, fd_set *, struct timeval *));
|
||||||
void rb_thread_wait_for _((struct timeval));
|
void rb_thread_wait_for _((struct timeval));
|
||||||
VALUE rb_thread_current _((void));
|
VALUE rb_thread_current _((void));
|
||||||
|
|
|
@ -73,6 +73,7 @@ class SimpleDelegator<Delegator
|
||||||
end
|
end
|
||||||
|
|
||||||
def __setobj__(obj)
|
def __setobj__(obj)
|
||||||
|
raise ArgumentError, "cannot delegate to self" if self.equal?(obj)
|
||||||
@_sd_obj = obj
|
@_sd_obj = obj
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -110,6 +111,7 @@ def DelegateClass(superclass)
|
||||||
@_dc_obj
|
@_dc_obj
|
||||||
end
|
end
|
||||||
def __setobj__(obj)
|
def __setobj__(obj)
|
||||||
|
raise ArgumentError, "cannot delegate to self" if self.equal?(obj)
|
||||||
@_dc_obj = obj
|
@_dc_obj = obj
|
||||||
end
|
end
|
||||||
def clone
|
def clone
|
||||||
|
|
|
@ -302,8 +302,8 @@ The variable ruby-indent-level controls the amount of indentation.
|
||||||
(defun ruby-expr-beg (&optional option)
|
(defun ruby-expr-beg (&optional option)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(store-match-data nil)
|
(store-match-data nil)
|
||||||
(let ((start (point))
|
(let ((space (skip-chars-backward " \t"))
|
||||||
(space (skip-chars-backward " \t")))
|
(start (point)))
|
||||||
(cond
|
(cond
|
||||||
((bolp) t)
|
((bolp) t)
|
||||||
((progn
|
((progn
|
||||||
|
|
|
@ -84,10 +84,6 @@ extern int memcmp _((char *, char *, int));
|
||||||
extern void *memmove _((void *, void *, int));
|
extern void *memmove _((void *, void *, int));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_MKDIR
|
|
||||||
extern int mkdir _((char *, int));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#ifndef HAVE_MODF
|
#ifndef HAVE_MODF
|
||||||
extern double modf _((double, double *));
|
extern double modf _((double, double *));
|
||||||
|
|
104
missing/mkdir.c
104
missing/mkdir.c
|
@ -1,104 +0,0 @@
|
||||||
/*
|
|
||||||
* Written by Robert Rother, Mariah Corporation, August 1985.
|
|
||||||
*
|
|
||||||
* If you want it, it's yours. All I ask in return is that if you
|
|
||||||
* figure out how to do this in a Bourne Shell script you send me
|
|
||||||
* a copy.
|
|
||||||
* sdcsvax!rmr or rmr@uscd
|
|
||||||
*
|
|
||||||
* Severely hacked over by John Gilmore to make a 4.2BSD compatible
|
|
||||||
* subroutine. 11Mar86; hoptoad!gnu
|
|
||||||
*
|
|
||||||
* Modified by rmtodd@uokmax 6-28-87 -- when making an already existing dir,
|
|
||||||
* subroutine didn't return EEXIST. It does now.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <errno.h>
|
|
||||||
/*
|
|
||||||
* Make a directory.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
mkdir (dpath, dmode)
|
|
||||||
char *dpath;
|
|
||||||
int dmode;
|
|
||||||
{
|
|
||||||
int cpid, status;
|
|
||||||
struct stat statbuf;
|
|
||||||
|
|
||||||
if (stat (dpath, &statbuf) == 0)
|
|
||||||
{
|
|
||||||
errno = EEXIST; /* Stat worked, so it already exists */
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If stat fails for a reason other than non-existence, return error */
|
|
||||||
if (errno != ENOENT)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
switch (cpid = fork ())
|
|
||||||
{
|
|
||||||
|
|
||||||
case -1: /* Error in fork() */
|
|
||||||
return (-1); /* Errno is set already */
|
|
||||||
|
|
||||||
case 0: /* Child process */
|
|
||||||
/*
|
|
||||||
* Cheap hack to set mode of new directory. Since this
|
|
||||||
* child process is going away anyway, we zap its umask.
|
|
||||||
* FIXME, this won't suffice to set SUID, SGID, etc. on this
|
|
||||||
* directory. Does anybody care?
|
|
||||||
*/
|
|
||||||
status = umask (0); /* Get current umask */
|
|
||||||
status = umask (status | (0777 & ~dmode)); /* Set for mkdir */
|
|
||||||
execl ("/bin/mkdir", "mkdir", dpath, (char *) 0);
|
|
||||||
_exit (-1); /* Can't exec /bin/mkdir */
|
|
||||||
|
|
||||||
default: /* Parent process */
|
|
||||||
while (cpid != wait (&status)); /* Wait for kid to finish */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0)
|
|
||||||
{
|
|
||||||
errno = EIO; /* We don't know why, but */
|
|
||||||
return -1; /* /bin/mkdir failed */
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
rmdir (dpath)
|
|
||||||
char *dpath;
|
|
||||||
{
|
|
||||||
int cpid, status;
|
|
||||||
struct stat statbuf;
|
|
||||||
|
|
||||||
if (stat (dpath, &statbuf) != 0)
|
|
||||||
{
|
|
||||||
/* Stat just set errno. We don't have to */
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (cpid = fork ())
|
|
||||||
{
|
|
||||||
|
|
||||||
case -1: /* Error in fork() */
|
|
||||||
return (-1); /* Errno is set already */
|
|
||||||
|
|
||||||
case 0: /* Child process */
|
|
||||||
execl ("/bin/rmdir", "rmdir", dpath, (char *) 0);
|
|
||||||
_exit (-1); /* Can't exec /bin/mkdir */
|
|
||||||
|
|
||||||
default: /* Parent process */
|
|
||||||
while (cpid != wait (&status)); /* Wait for kid to finish */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WIFSIGNALED (status) || WEXITSTATUS (status) != 0)
|
|
||||||
{
|
|
||||||
errno = EIO; /* We don't know why, but */
|
|
||||||
return -1; /* /bin/rmdir failed */
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
3
signal.c
3
signal.c
|
@ -33,6 +33,7 @@ static struct signals {
|
||||||
char *signm;
|
char *signm;
|
||||||
int signo;
|
int signo;
|
||||||
} siglist [] = {
|
} siglist [] = {
|
||||||
|
{"EXIT", 0},
|
||||||
#ifdef SIGHUP
|
#ifdef SIGHUP
|
||||||
{"HUP", SIGHUP},
|
{"HUP", SIGHUP},
|
||||||
#endif
|
#endif
|
||||||
|
@ -508,7 +509,7 @@ static RETSIGTYPE
|
||||||
sigexit(sig)
|
sigexit(sig)
|
||||||
int sig;
|
int sig;
|
||||||
{
|
{
|
||||||
rb_exit(0);
|
rb_thread_signal_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue