You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2008/02/12 10:18:29 UTC
svn commit: r620728 -
/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/procimpl.c
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;
}