プロジェクト

全般

プロフィール

バグ #2772

WindowsでCtrl+Cで終了しない

n-andoほぼ11年前に追加. ほぼ11年前に更新.

ステータス:
終了
優先度:
通常
担当者:
対象バージョン:
-
開始日:
2013/06/27
期日:
進捗率:

100%

予定工数:

説明

Windowsではコンポーネント実行時にCtrl+Cで終了しない

関係しているリビジョン

リビジョン 589 (差分)
n-andoほぼ11年前に追加

Problem about signal.alarm() on Windows has been solved. refs #2772

履歴

#1 n-andoほぼ11年前に更新

  • ステータス新規 から 解決 に変更
  • 進捗率0 から 100 に変更

先日追加したalarm関数がwindowsではブロックされてしまう。
http://ja.softuses.com/32527 を参考に以下のクラスを追加。

##
# @if jp
# @brief Windows用Alarm
# @else
# @brief Alarm for Windows
# @endif
import os
import time
import threading

class Alarm (threading.Thread):
  def __init__ (self, timeout):
    threading.Thread.__init__ (self)
    self.timeout = timeout
    self.setDaemon(True)
  def run (self):
    time.sleep(self.timeout)
    os._exit(1)

handler関数を以下のように修正。

##
# @if jp
# @brief 終了処理
#
# マネージャを終了させる
#
# @param signum シグナル番号
# @param frame 現在のスタックフレーム
#
# @else
#
# @endif
def handler(signum, frame):
  mgr = OpenRTM_aist.Manager.instance()
  mgr.terminate()
  import os
  if os.sep == '/':
    signal.alarm(2)
  else:
    alarm = Alarm(2)
    alarm.start()

かなり強引だが、WindowsでCtrl+Cが効き、RTCの正常終了とネームサービスからの削除を確認。

#2 n-andoほぼ11年前に更新

  • ステータス解決 から 終了 に変更

他の形式にエクスポート: Atom PDF