You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2012/12/05 06:35:27 UTC

svn commit: r1417283 - in /hadoop/common/branches/branch-1-win: CHANGES.branch-1-win.txt src/core/org/apache/hadoop/util/ProcessTree.java src/test/org/apache/hadoop/mapred/TestKillSubProcesses.java src/winutils/task.c

Author: suresh
Date: Wed Dec  5 05:35:26 2012
New Revision: 1417283

URL: http://svn.apache.org/viewvc?rev=1417283&view=rev
Log:
HADOOP-9102. winutils task isAlive does not return a non-zero exit code if the requested task is not alive. Contributed by Chris Nauroth.

Modified:
    hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt
    hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcessTree.java
    hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestKillSubProcesses.java
    hadoop/common/branches/branch-1-win/src/winutils/task.c

Modified: hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt?rev=1417283&r1=1417282&r2=1417283&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt (original)
+++ hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt Wed Dec  5 05:35:26 2012
@@ -234,3 +234,6 @@ Branch-hadoop-1-win - unreleased
 
     HADOOP-9110. HADOOP-9110. winutils ls off-by-one error indexing MONTHS array
     can cause access violation. (Chris Nauroth via suresh)
+
+    HADOOP-9102. winutils task isAlive does not return a non-zero exit code if
+    the requested task is not alive. (Chris Nauroth via suresh)

Modified: hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcessTree.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcessTree.java?rev=1417283&r1=1417282&r2=1417283&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcessTree.java (original)
+++ hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcessTree.java Wed Dec  5 05:35:26 2012
@@ -237,6 +237,8 @@ public class ProcessTree {
         shexec.execute();
         String result = shexec.getOutput();
         return (result.contains("IsAlive"));
+      } catch (ExitCodeException ee) {
+        return false;
       } catch (IOException ioe) {
         LOG.warn("Error executing shell command", ioe);
         return false;

Modified: hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestKillSubProcesses.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestKillSubProcesses.java?rev=1417283&r1=1417282&r2=1417283&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestKillSubProcesses.java (original)
+++ hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/mapred/TestKillSubProcesses.java Wed Dec  5 05:35:26 2012
@@ -284,8 +284,12 @@ public class TestKillSubProcesses extend
     // Checking if the descendant processes of map task are killed properly
     if(ProcessTree.isSetsidAvailable) {
       if(Shell.WINDOWS) {
-        String result = runAliveCommand(pid);
-        assertTrue("Map process tree not alive", !result.contains("IsAlive"));
+        try {
+          runAliveCommand(pid);
+          fail("Map process tree not alive");
+        } catch (ExitCodeException e) {
+          // expected
+        }
       } else {
         for(int i=0; i <= numLevelsOfSubProcesses; i++) {
           String childPid = UtilsForTests.getPidFromPidFile(

Modified: hadoop/common/branches/branch-1-win/src/winutils/task.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/task.c?rev=1417283&r1=1417282&r2=1417283&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/task.c (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/task.c Wed Dec  5 05:35:26 2012
@@ -22,6 +22,8 @@
 #define PSAPI_VERSION 1
 #pragma comment(lib, "psapi.lib")
 
+#define ERROR_TASK_NOT_ALIVE 1
+
 // List of different task related command line options supported by
 // winutils.
 typedef enum TaskCommandOptionType
@@ -401,6 +403,12 @@ int Task(int argc, wchar_t *argv[])
     {
       fwprintf(stdout, L"IsAlive,%d\n", numProcs);
     }
+    else
+    {
+      dwErrorCode = ERROR_TASK_NOT_ALIVE;
+      ReportErrorCode(L"isTaskAlive returned false", dwErrorCode);
+      goto TaskExit;
+    }
   } else if (command == TaskKill)
   {
     // Check if task jobobject
@@ -450,4 +458,4 @@ void TaskUsage()
     and comma separated info per process\n\
     ProcessId,VirtualMemoryCommitted(bytes),\n\
     WorkingSetSize(bytes),CpuTime(Millisec,Kernel+User)\n");
-}
\ No newline at end of file
+}