Bug #5812 ยป thread_signal.patch
| test/ruby/test_thread.rb | ||
|---|---|---|
|
Process.kill(:SIGINT, pid)
|
||
|
Process.wait(pid)
|
||
|
s = $?
|
||
|
assert_equal([false, true, false],
|
||
|
[s.exited?, s.signaled?, s.stopped?],
|
||
|
"[s.exited?, s.signaled?, s.stopped?]")
|
||
|
if /mswin|mingw/ =~ RUBY_PLATFORM
|
||
|
assert_equal(pid, s.pid)
|
||
|
else
|
||
|
assert_equal([false, true, false],
|
||
|
[s.exited?, s.signaled?, s.stopped?],
|
||
|
"[s.exited?, s.signaled?, s.stopped?]")
|
||
|
end
|
||
|
t1 = Time.now.to_f
|
||
|
assert_in_delta(t1 - t0, 1, 1)
|
||
|
end
|
||
| test/zlib/test_zlib.rb | ||
|---|---|---|
|
t.close
|
||
|
Zlib::GzipWriter.open(t.path) {|gz| gz.print("foo") }
|
||
|
f = open(t.path)
|
||
|
f.binmode
|
||
|
assert_equal("foo", Zlib::GzipReader.wrap(f) {|gz| gz.read })
|
||
|
assert_raise(IOError) { f.close }
|
||
|
end
|
||
| thread_win32.c | ||
|---|---|---|
|
int
|
||
|
rb_w32_wait_events_blocking(HANDLE *events, int num, DWORD timeout)
|
||
|
{
|
||
|
return w32_wait_events(events, num, timeout, GET_THREAD());
|
||
|
return w32_wait_events(events, num, timeout, ruby_thread_from_native());
|
||
|
}
|
||
|
int
|
||
| ... | ... | |
|
int ret;
|
||
|
BLOCKING_REGION(ret = rb_w32_wait_events_blocking(events, num, timeout),
|
||
|
ubf_handle, GET_THREAD());
|
||
|
ubf_handle, ruby_thread_from_native());
|
||
|
return ret;
|
||
|
}
|
||
| ... | ... | |
|
int
|
||
|
rb_w32_sleep(unsigned long msec)
|
||
|
{
|
||
|
return w32_wait_events(0, 0, msec, GET_THREAD());
|
||
|
return w32_wait_events(0, 0, msec, ruby_thread_from_native());
|
||
|
}
|
||
|
int WINAPI
|
||
| ... | ... | |
|
int ret;
|
||
|
BLOCKING_REGION(ret = rb_w32_sleep(msec),
|
||
|
ubf_handle, GET_THREAD());
|
||
|
ubf_handle, ruby_thread_from_native());
|
||
|
return ret;
|
||
|
}
|
||
| win32/win32.c | ||
|---|---|---|
|
aStartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
||
|
}
|
||
|
dwCreationFlags = (NORMAL_PRIORITY_CLASS);
|
||
|
dwCreationFlags = (CREATE_NEW_PROCESS_GROUP | NORMAL_PRIORITY_CLASS);
|
||
|
if (lstrlenW(cmd) > 32767) {
|
||
|
child->pid = 0; /* release the slot */
|
||
| ... | ... | |
|
case SIGINT:
|
||
|
RUBY_CRITICAL({
|
||
|
if (!GenerateConsoleCtrlEvent(CTRL_C_EVENT, (DWORD)pid)) {
|
||
|
DWORD ctrlEvent = CTRL_C_EVENT;
|
||
|
if (pid != 0) {
|
||
|
/* CTRL+C signal cannot be generated for process groups.
|
||
|
* Instead, we use CTRL+BREAK signal. */
|
||
|
ctrlEvent = CTRL_BREAK_EVENT;
|
||
|
}
|
||
|
if (!GenerateConsoleCtrlEvent(ctrlEvent, (DWORD)pid)) {
|
||
|
if ((err = GetLastError()) == 0)
|
||
|
errno = EPERM;
|
||
|
else
|
||
| ... | ... | |
|
}
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
err = GetLastError();
|
||
|
errno = map_errno(err);
|
||
|
}
|
||
|
if (pol) {
|
||
|
CloseHandle(ol.hEvent);
|
||
| ... | ... | |
|
ret += read;
|
||
|
if (read >= len) {
|
||
|
buf = (char *)buf + read;
|
||
|
if (!(isconsole && len == 1 && (!islineinput || *((char *)buf - 1) == '\n')) && size > 0)
|
||
|
if (err != ERROR_OPERATION_ABORTED &&
|
||
|
!(isconsole && len == 1 && (!islineinput || *((char *)buf - 1) == '\n')) && size > 0)
|
||
|
goto retry;
|
||
|
}
|
||
|
if (read == 0)
|
||