ruby-changes:36956
From: akr <ko1@a...>
Date: Sat, 27 Dec 2014 17:03:46 +0900 (JST)
Subject: [ruby-changes:36956] akr:r49037 (trunk): * process.c: Unused code removed.
akr 2014-12-27 17:03:29 +0900 (Sat, 27 Dec 2014) New Revision: 49037 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49037 Log: * process.c: Unused code removed. It seems waitpid() is universaly available on POSIX platforms. Modified files: trunk/ChangeLog trunk/process.c Index: ChangeLog =================================================================== --- ChangeLog (revision 49036) +++ ChangeLog (revision 49037) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Dec 27 16:54:05 2014 Tanaka Akira <akr@f...> + + * process.c: Unused code removed. + It seems waitpid() is universaly available on POSIX platforms. + Sat Dec 27 15:08:27 2014 Eric Wong <e@8...> * vm_core.h (rb_vm_living_threads_insert): preserve order Index: process.c =================================================================== --- process.c (revision 49036) +++ process.c (revision 49037) @@ -738,54 +738,24 @@ pst_wcoredump(VALUE st) https://github.com/ruby/ruby/blob/trunk/process.c#L738 #endif } -#if !defined(HAVE_WAITPID) && !defined(HAVE_WAIT4) -#define NO_WAITPID -static st_table *pid_tbl; - -struct wait_data { - rb_pid_t pid; - int status; -}; - -static int -wait_each(rb_pid_t pid, int status, struct wait_data *data) -{ - if (data->status != -1) return ST_STOP; - - data->pid = pid; - data->status = status; - return ST_DELETE; -} - -static int -waitall_each(rb_pid_t pid, int status, VALUE ary) -{ - rb_last_status_set(status, pid); - rb_ary_push(ary, rb_assoc_new(PIDT2NUM(pid), rb_last_status_get())); - return ST_DELETE; -} -#else struct waitpid_arg { rb_pid_t pid; int flags; int *st; }; -#endif static void * rb_waitpid_blocking(void *data) { rb_pid_t result; -#ifndef NO_WAITPID struct waitpid_arg *arg = data; -#endif -#if defined NO_WAITPID - result = wait(data); -#elif defined HAVE_WAITPID +#if defined HAVE_WAITPID result = waitpid(arg->pid, arg->st, arg->flags); -#else /* HAVE_WAIT4 */ +#elif defined HAVE_WAIT4 result = wait4(arg->pid, arg->st, arg->flags, NULL); +#else +# error waitpid or wait4 is required. #endif return (void *)(VALUE)result; @@ -795,7 +765,6 @@ rb_pid_t https://github.com/ruby/ruby/blob/trunk/process.c#L765 rb_waitpid(rb_pid_t pid, int *st, int flags) { rb_pid_t result; -#ifndef NO_WAITPID struct waitpid_arg arg; retry: @@ -811,48 +780,6 @@ rb_waitpid(rb_pid_t pid, int *st, int fl https://github.com/ruby/ruby/blob/trunk/process.c#L780 } return (rb_pid_t)-1; } -#else /* NO_WAITPID */ - if (pid_tbl) { - st_data_t status, piddata = (st_data_t)pid; - if (pid == (rb_pid_t)-1) { - struct wait_data data; - data.pid = (rb_pid_t)-1; - data.status = -1; - st_foreach(pid_tbl, wait_each, (st_data_t)&data); - if (data.status != -1) { - rb_last_status_set(data.status, data.pid); - return data.pid; - } - } - else if (st_delete(pid_tbl, &piddata, &status)) { - rb_last_status_set(*st = (int)status, pid); - return pid; - } - } - - if (flags) { - rb_raise(rb_eArgError, "can't do waitpid with flags"); - } - - for (;;) { - result = (rb_pid_t)(VALUE)rb_thread_blocking_region(rb_waitpid_blocking, - st, RUBY_UBF_PROCESS, 0); - if (result < 0) { - if (errno == EINTR) { - rb_thread_schedule(); - continue; - } - return (rb_pid_t)-1; - } - if (result == pid || pid == (rb_pid_t)-1) { - break; - } - if (!pid_tbl) - pid_tbl = st_init_numtable(); - st_insert(pid_tbl, pid, (st_data_t)st); - if (!rb_thread_alone()) rb_thread_schedule(); - } -#endif if (result > 0) { rb_last_status_set(*st, result); } @@ -1001,34 +928,15 @@ proc_waitall(void) https://github.com/ruby/ruby/blob/trunk/process.c#L928 rb_secure(2); result = rb_ary_new(); -#ifdef NO_WAITPID - if (pid_tbl) { - st_foreach(pid_tbl, waitall_each, result); - } -#else rb_last_status_clear(); -#endif for (pid = -1;;) { -#ifdef NO_WAITPID - pid = wait(&status); -#else pid = rb_waitpid(-1, &status, 0); -#endif if (pid == -1) { if (errno == ECHILD) break; -#ifdef NO_WAITPID - if (errno == EINTR) { - rb_thread_schedule(); - continue; - } -#endif rb_sys_fail(0); } -#ifdef NO_WAITPID - rb_last_status_set(status, pid); -#endif rb_ary_push(result, rb_assoc_new(PIDT2NUM(pid), rb_last_status_get())); } return result; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/