Project

General

Profile

Bug #11340

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

Added by takkanm (三村 益隆) about 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
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
#1

Updated by usa (Usaku NAKAMURA) about 5 years ago

  • Status changed from Open to Closed

Applied in changeset r51202.


  • win32/win32.c (waitpid): return immediately if interrupted. reported by [ruby-dev:49176] [Bug #11340]

Updated by nobu (Nobuyoshi Nakada) about 5 years ago

  • Description updated (diff)

Updated by usa (Usaku NAKAMURA) about 5 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
#4

Updated by nagachika (Tomoyuki Chikanaga) about 5 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.

#5

Updated by usa (Usaku NAKAMURA) about 5 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.

Also available in: Atom PDF