Skip to content

Commit 528b1f5

Browse files
author
matz
committed
wait
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent ab801db commit 528b1f5

File tree

3 files changed

+25
-36
lines changed

3 files changed

+25
-36
lines changed

compar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ cmp_between(x, min, max)
7676
VALUE x, min, max;
7777
{
7878
VALUE c = rb_funcall(x, cmp, 1, min);
79-
int t = NUM2INT(c);
79+
long t = NUM2LONG(c);
8080
if (t < 0) return FALSE;
8181

8282
c = rb_funcall(x, cmp, 1, max);
83-
t = NUM2INT(c);
83+
t = NUM2LONG(c);
8484
if (t > 0) return FALSE;
8585
return TRUE;
8686
}

lib/delegate.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def initialize(obj)
2424
preserved |= t.instance_methods
2525
break if t == Delegator
2626
end
27-
preserved -= ["__getobj__","to_s","to_a","inspect","hash","eql?","==","=~","==="]
27+
preserved -= ["to_s","to_a","inspect","hash","eql?","==","=~","==="]
2828
for method in obj.methods
2929
next if preserved.include? method
3030
eval <<EOS

process.c

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ get_ppid()
6666

6767
VALUE last_status = Qnil;
6868

69-
#if !defined(HAVE_WAITPID) && !defined(HAVE_WAIT4)
70-
static st_table *pid_tbl;
71-
#else
69+
#if defined(HAVE_WAITPID) || defined(HAVE_WAIT4)
7270
# define WAIT_CALL
71+
#else
72+
static st_table *pid_tbl;
7373
#endif
7474

7575
static int
@@ -79,16 +79,20 @@ rb_waitpid(pid, flags, st)
7979
int *st;
8080
{
8181
int result;
82-
#if defined(THREAD) && (defined(HAVE_WAITPID) || defined(HAVE_WAIT4))
82+
#ifdef WAIT_CALL
83+
#if defined(THREAD)
8384
int oflags = flags;
8485
if (!thread_alone()) { /* there're other threads to run */
8586
flags |= WNOHANG;
8687
}
8788
#endif
8889

89-
#ifdef HAVE_WAITPID
9090
retry:
91+
#ifdef HAVE_WAITPID
9192
result = waitpid(pid, st, flags);
93+
#else /* HAVE_WAIT4 */
94+
result = wait4(pid, st, flags, NULL);
95+
#endif
9296
if (result < 0) {
9397
if (errno == EINTR) {
9498
#ifdef THREAD
@@ -106,26 +110,7 @@ rb_waitpid(pid, flags, st)
106110
goto retry;
107111
}
108112
#endif
109-
#else
110-
#ifdef HAVE_WAIT4
111-
retry:
112-
113-
result = wait4(pid, st, flags, NULL);
114-
if (result < 0) {
115-
if (errno == EINTR) {
116-
goto retry;
117-
}
118-
return -1;
119-
}
120-
#ifdef THREAD
121-
if (result == 0) {
122-
if (oflags & WNOHANG) return 0;
123-
thread_schedule();
124-
if (thread_alone()) flags = oflags;
125-
goto retry;
126-
}
127-
#endif
128-
#else
113+
#else /* WAIT_CALL */
129114
if (pid_tbl && st_lookup(pid_tbl, pid, st)) {
130115
last_status = INT2FIX(*st);
131116
st_delete(pid_tbl, &pid, NULL);
@@ -153,8 +138,10 @@ rb_waitpid(pid, flags, st)
153138
if (!pid_tbl)
154139
pid_tbl = st_init_numtable();
155140
st_insert(pid_tbl, pid, st);
156-
}
141+
#ifdef THREAD
142+
if (!thread_alone()) thread_schedule();
157143
#endif
144+
}
158145
#endif
159146
last_status = INT2FIX(*st);
160147
return result;
@@ -192,19 +179,21 @@ f_wait()
192179
last_status = data.status;
193180
return INT2FIX(data.pid);
194181
}
195-
#endif
196182

197183
while ((pid = wait(&state)) < 0) {
198-
if (errno == EINTR) {
184+
if (errno == EINTR) {
199185
#ifdef THREAD
200-
thread_schedule();
186+
thread_schedule();
201187
#endif
202-
continue;
203-
}
204-
if (errno == ECHILD) return Qnil;
205-
rb_sys_fail(0);
188+
continue;
189+
}
190+
rb_sys_fail(0);
206191
}
207192
last_status = INT2FIX(state);
193+
#else
194+
if ((pid = rb_waitpid(-1, 0, &state)) < 0)
195+
rb_sys_fail(0);
196+
#endif
208197
return INT2FIX(pid);
209198
}
210199

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy