Project

General

Profile

Actions

Bug #11340

closed

Windows で Timeout.timeout を使って Process.waitpid を監視しても timeout が正しく動かない

Added by takkanm (三村 益隆) over 9 years ago. Updated over 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-dev:49176]

Description

以下のような、コードでプロセスの実行時間監視をしていたところ、
Windows とその他の環境で異なります。

require 'timeout'

pid = Process.spawn('sleep', '10')
puts Time.now
begin
  Timeout.timeout(1) {
    Process.waitpid(pid)
  }
rescue => e
  p e
end
puts Time.now

Linux 等の場合、timeout で設定した時間で例外があがるのですが、
Windows のときは Process.waitpid が完了してから Timeout のスレッドからの例外をうけとっているように見えます。

Mac 10.10.3 (ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]) のとき (Linux でも同様でした

2015-07-09 13:48:43 +0900
#<Timeout::Error: execution expired>
2015-07-09 13:48:44 +0900

Windows 8.1 (ruby 2.2.2p95 (2015-04-13 revision 50295) [i386-mingw32])のとき

2015-07-08 21:10:23 -0700
#<Timeout::Error: execution expired>
2015-07-08 21:10:33 -0700
Actions #1

Updated by usa (Usaku NAKAMURA) over 9 years ago

  • Status changed from Open to Closed

Applied in changeset r51202.


Updated by nobu (Nobuyoshi Nakada) over 9 years ago

  • Description updated (diff)

Updated by usa (Usaku NAKAMURA) over 9 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: WONTFIX, 2.1: REQUIRED, 2.2: REQUIRED
Actions #4

Updated by nagachika (Tomoyuki Chikanaga) over 9 years ago

  • Backport changed from 2.0.0: WONTFIX, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: WONTFIX, 2.1: REQUIRED, 2.2: DONE

Backported into ruby_2_2 branch at r51552.

Actions #5

Updated by usa (Usaku NAKAMURA) over 9 years ago

  • Backport changed from 2.0.0: WONTFIX, 2.1: REQUIRED, 2.2: DONE to 2.0.0: WONTFIX, 2.1: DONE, 2.2: DONE

ruby_2_1 r51607 merged revision(s) 51202,51203,51204.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0