1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* process.c (SIZEOF_RLIM_T): err if size of rlim_t is not set.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2004-12-23 14:43:30 +00:00
parent 4155f97bb0
commit a68e68b227
2 changed files with 24 additions and 24 deletions

View file

@ -1,8 +1,10 @@
Thu Dec 23 23:36:28 2004 Nobuyoshi Nakada <nobu@ruby-lang.org> Thu Dec 23 23:43:24 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* process.c (proc_setgroups): check if the argument lenght is * process.c (proc_setgroups): check if the argument lenght is
modified. fixed: [ruby-dev:25285] modified. fixed: [ruby-dev:25285]
* process.c (SIZEOF_RLIM_T): err if size of rlim_t is not set.
Thu Dec 23 19:08:41 2004 Tanaka Akira <akr@m17n.org> Thu Dec 23 19:08:41 2004 Tanaka Akira <akr@m17n.org>
* rubyio.h: rename FMODE_UNSEEKABLE to FMODE_DUPLEX. * rubyio.h: rename FMODE_UNSEEKABLE to FMODE_DUPLEX.

View file

@ -819,7 +819,7 @@ proc_waitall()
if (pid == -1) { if (pid == -1) {
if (errno == ECHILD) if (errno == ECHILD)
break; break;
if (errno == EINTR) { if (errno == EINTR) {
rb_thread_schedule(); rb_thread_schedule();
continue; continue;
} }
@ -1943,7 +1943,6 @@ proc_setpriority(obj, which, who, prio)
#endif #endif
} }
#if SIZEOF_RLIM_T
#if SIZEOF_RLIM_T == SIZEOF_INT #if SIZEOF_RLIM_T == SIZEOF_INT
# define RLIM2NUM(v) UINT2NUM(v) # define RLIM2NUM(v) UINT2NUM(v)
# define NUM2RLIM(v) NUM2UINT(v) # define NUM2RLIM(v) NUM2UINT(v)
@ -1956,7 +1955,6 @@ proc_setpriority(obj, which, who, prio)
#else #else
# error cannot find an integer type which size is same as rlim_t. # error cannot find an integer type which size is same as rlim_t.
#endif #endif
#endif
/* /*
* call-seq: * call-seq:
@ -1986,7 +1984,7 @@ proc_getrlimit(VALUE obj, VALUE resource)
rb_secure(2); rb_secure(2);
if (getrlimit(NUM2INT(resource), &rlim) < 0) { if (getrlimit(NUM2INT(resource), &rlim) < 0) {
rb_sys_fail("getrlimit"); rb_sys_fail("getrlimit");
} }
return rb_assoc_new(RLIM2NUM(rlim.rlim_cur), RLIM2NUM(rlim.rlim_max)); return rb_assoc_new(RLIM2NUM(rlim.rlim_cur), RLIM2NUM(rlim.rlim_max));
#else #else
@ -2036,7 +2034,7 @@ proc_setrlimit(VALUE obj, VALUE resource, VALUE rlim_cur, VALUE rlim_max)
rlim.rlim_max = NUM2RLIM(rlim_max); rlim.rlim_max = NUM2RLIM(rlim_max);
if (setrlimit(NUM2INT(resource), &rlim) < 0) { if (setrlimit(NUM2INT(resource), &rlim) < 0) {
rb_sys_fail("setrlimit"); rb_sys_fail("setrlimit");
} }
return Qnil; return Qnil;
#else #else
@ -2653,11 +2651,11 @@ proc_getgroups(VALUE obj)
ngroups = getgroups(maxgroups, groups); ngroups = getgroups(maxgroups, groups);
if (ngroups == -1) if (ngroups == -1)
rb_sys_fail(0); rb_sys_fail(0);
ary = rb_ary_new(); ary = rb_ary_new();
for (i = 0; i < ngroups; i++) for (i = 0; i < ngroups; i++)
rb_ary_push(ary, INT2NUM(groups[i])); rb_ary_push(ary, INT2NUM(groups[i]));
return ary; return ary;
#else #else
@ -2693,15 +2691,15 @@ proc_setgroups(VALUE obj, VALUE ary)
ngroups = RARRAY(ary)->len; ngroups = RARRAY(ary)->len;
if (ngroups > maxgroups) if (ngroups > maxgroups)
rb_raise(rb_eArgError, "too many groups, %d max", maxgroups); rb_raise(rb_eArgError, "too many groups, %d max", maxgroups);
groups = ALLOCA_N(gid_t, ngroups); groups = ALLOCA_N(gid_t, ngroups);
for (i = 0; i < ngroups && i < RARRAY(ary)->len; i++) { for (i = 0; i < ngroups && i < RARRAY(ary)->len; i++) {
VALUE g = RARRAY(ary)->ptr[i]; VALUE g = RARRAY(ary)->ptr[i];
if (FIXNUM_P(g)) { if (FIXNUM_P(g)) {
groups[i] = FIX2INT(g); groups[i] = FIX2INT(g);
} }
else { else {
VALUE tmp = rb_check_string_type(g); VALUE tmp = rb_check_string_type(g);
@ -2721,7 +2719,7 @@ proc_setgroups(VALUE obj, VALUE ary)
i = setgroups(ngroups, groups); i = setgroups(ngroups, groups);
if (i == -1) if (i == -1)
rb_sys_fail(0); rb_sys_fail(0);
return proc_getgroups(obj); return proc_getgroups(obj);
#else #else
@ -2833,25 +2831,25 @@ proc_daemon(argc, argv)
return INT2FIX(n); return INT2FIX(n);
#elif defined(HAVE_FORK) #elif defined(HAVE_FORK)
switch (rb_fork(0, 0, 0)) { switch (rb_fork(0, 0, 0)) {
case -1: case -1:
return (-1); return (-1);
case 0: case 0:
break; break;
default: default:
_exit(0); _exit(0);
} }
proc_setsid(); proc_setsid();
if (!RTEST(nochdir)) if (!RTEST(nochdir))
(void)chdir("/"); (void)chdir("/");
if (!RTEST(noclose) && (n = open("/dev/null", O_RDWR, 0)) != -1) { if (!RTEST(noclose) && (n = open("/dev/null", O_RDWR, 0)) != -1) {
(void)dup2(n, 0); (void)dup2(n, 0);
(void)dup2(n, 1); (void)dup2(n, 1);
(void)dup2(n, 2); (void)dup2(n, 2);
if (n > 2) if (n > 2)
(void)close (n); (void)close (n);
} }
return INT2FIX(0); return INT2FIX(0);
#else #else