harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r620728 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/procimpl.c
Date Tue, 12 Feb 2008 09:18:29 GMT
Author: hindessm
Date: Tue Feb 12 01:18:15 2008
New Revision: 620728

URL: http://svn.apache.org/viewvc?rev=620728&view=rev
Log:
Improve error reporting from forked child by passing errno back to parent
instead of dummy value.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/procimpl.c

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/procimpl.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/procimpl.c?rev=620728&r1=620727&r2=620728&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/procimpl.c (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/procimpl.c Tue
Feb 12 01:18:15 2008
@@ -173,8 +173,7 @@
 
     if (dir) {
       if (chdir(dir) == -1) {
-        /* TODO: write errno so parent can return correct error */
-        write(execvFailure[1], &dummy, 1);
+        write(execvFailure[1], &errno, sizeof(errno));
         exit(-1);
       }
     }
@@ -189,7 +188,7 @@
     /* ===================================================== */
 
     /* if we get here ==> tell the parent that the execv failed ! */
-    write(execvFailure[1], &dummy, 1);
+    write(execvFailure[1], &errno, sizeof(errno));
     /* If the exec failed, we must exit or there will be two VM processes running. */
     exit(rc);
   } else {
@@ -225,6 +224,9 @@
     if (avail > 0) {
       rc = -1;                  /* failure of the execv */
       noDataInThePipe = 0;
+      if (read(execvFailure[0], &error, sizeof(error)) == sizeof(error)) {
+        goto error_with_error_set;
+      }
     }
     nbLoop = 0;
     while (noDataInThePipe) {
@@ -251,6 +253,9 @@
       if (avail > 0) {
         rc = -1;                /* failure of the execv */
         noDataInThePipe = 0;
+        if (read(execvFailure[0], &error, sizeof(error)) == sizeof(error)) {
+          goto error_with_error_set;
+        }
       }
     }                           /* end of the loop. rc==-1 iff the execv failed */
 
@@ -270,6 +275,8 @@
 
   error = errno;
 
+ error_with_error_set:
+
   if (execvFailure[0]) close(execvFailure[0]);
   if (execvFailure[1]) close(execvFailure[1]);
 
@@ -294,6 +301,9 @@
     break;
   case EMFILE:
     result = 1003;
+    break;
+  case ENOENT:
+    result = 1004;
     break;
   }
 



Mime
View raw message