[前][次][番号順一覧][スレッド一覧]

ruby-changes:28497

From: usa <ko1@a...>
Date: Thu, 2 May 2013 11:34:27 +0900 (JST)
Subject: [ruby-changes:28497] usa:r40549 (trunk): * win32/win32.c (poll_child_status): [experimental] set the cause of

usa	2013-05-02 11:34:11 +0900 (Thu, 02 May 2013)

  New Revision: 40549

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40549

  Log:
    * win32/win32.c (poll_child_status): [experimental] set the cause of
      a child's death to status if its exitcode seems to be an error.

  Modified files:
    trunk/ChangeLog
    trunk/win32/win32.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40548)
+++ ChangeLog	(revision 40549)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu May  2 11:32:22 2013  NAKAMURA Usaku  <usa@r...>
+
+	* win32/win32.c (poll_child_status): [experimental] set the cause of
+	  a child's death to status if its exitcode seems to be an error.
+
 Thu May  2 11:24:00 2013  Zachary Scott  <zachary@z...>
 
 	* lib/yaml.rb: nodoc EngineManager, add History doc #8344
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 40548)
+++ win32/win32.c	(revision 40549)
@@ -3908,7 +3908,39 @@ poll_child_status(struct ChildRecord *ch https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L3908
         }
 	pid = child->pid;
 	CloseChildHandle(child);
-	if (stat_loc) *stat_loc = exitcode << 8;
+	if (stat_loc) {
+	    *stat_loc = exitcode << 8;
+	    if (exitcode & 0xC0000000) {
+		static struct {
+		    DWORD status;
+		    int sig;
+		} table[] = {
+		    {STATUS_ACCESS_VIOLATION,        SIGSEGV},
+		    {STATUS_ILLEGAL_INSTRUCTION,     SIGILL},
+		    {STATUS_PRIVILEGED_INSTRUCTION,  SIGILL},
+		    {STATUS_FLOAT_DENORMAL_OPERAND,  SIGFPE},
+		    {STATUS_FLOAT_DIVIDE_BY_ZERO,    SIGFPE},
+		    {STATUS_FLOAT_INEXACT_RESULT,    SIGFPE},
+		    {STATUS_FLOAT_INVALID_OPERATION, SIGFPE},
+		    {STATUS_FLOAT_OVERFLOW,          SIGFPE},
+		    {STATUS_FLOAT_STACK_CHECK,       SIGFPE},
+		    {STATUS_FLOAT_UNDERFLOW,         SIGFPE},
+		    {STATUS_FLOAT_MULTIPLE_FAULTS,   SIGFPE},
+		    {STATUS_FLOAT_MULTIPLE_TRAPS,    SIGFPE},
+		    {0, 0}
+		};
+		int i;
+		for (i = 0; table[i].status; i++) {
+		    if (table[i].status == exitcode) {
+			*stat_loc |= table[i].sig;
+			break;
+		    }
+		}
+		// if unknown status, assume SEGV
+		if (!table[i].status)
+		    *stat_loc |= SIGSEGV;
+	    }
+	}
 	return pid;
     }
     return 0;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]