--- a/Win32OperatingSystem.st Fri Sep 17 16:07:58 1999 +0200
+++ b/Win32OperatingSystem.st Fri Sep 17 16:09:08 1999 +0200
@@ -2764,6 +2764,8 @@
|ret in out err shellAndArgs errStream outStream inStream|
+ aCommandString isNil ifTrue:[^ nil].
+
anExternalInStream notNil ifTrue:[
in := anExternalInStream fileDescriptor.
] ifFalse:[
@@ -6317,217 +6319,217 @@
int retArray[MAXHANDLE];
if (__isNonNilObject(readFdArray)) {
- if (! __isArray(readFdArray)) {
- goto fail;
- }
- count = __arraySize(readFdArray);
-
- for (i=0; (i<count) && (numHandles < MAXHANDLE);i++) {
- fd = __ArrayInstPtr(readFdArray)->a_element[i];
- if (fd != nil) {
- HANDLE h;
-
- if (__isExternalAddress(fd)) {
- hArray[numHandles] = h = _HANDLEVal(fd);
- } else {
- hArray[numHandles] = h = (HANDLE) _get_osfhandle (__intVal(fd));
-
- if (ioctlsocket((SOCKET)h, FIONREAD, &res)==0) {
- if (res > 0) {
+ if (! __isArray(readFdArray)) {
+ goto fail;
+ }
+ count = __arraySize(readFdArray);
+
+ for (i=0; (i<count) && (numHandles < MAXHANDLE);i++) {
+ fd = __ArrayInstPtr(readFdArray)->a_element[i];
+ if (fd != nil) {
+ HANDLE h;
+
+ if (__isExternalAddress(fd)) {
+ hArray[numHandles] = h = _HANDLEVal(fd);
+ } else {
+ hArray[numHandles] = h = (HANDLE) _get_osfhandle (__intVal(fd));
+
+ if (ioctlsocket((SOCKET)h, FIONREAD, &res)==0) {
+ if (res > 0) {
#ifdef SELECT2DEBUGWIN32
- printf("no wait result=%d (this is a Socket fd=%x h=%x)\n", res, fd, h);
-#endif
- RETURN (fd);
- }
+ printf("no wait result=%d (this is a Socket fd=%x h=%x)\n", res, fd, h);
+#endif
+ RETURN (fd);
+ }
#ifdef SELECT2DEBUGWIN32
- printf("readWait Handle %d (this is a Socket fd=%x h=%x)\n", i, fd, h);
-#endif
- //if (!__isWinNT)
- // continue;
- } else {
- if (PeekNamedPipe((HANDLE)h, 0, 0, 0, &res, 0)) {
- if (1 /*res > 0*/) {
+ printf("readWait Handle %d (this is a Socket fd=%x h=%x)\n", i, fd, h);
+#endif
+ //if (!__isWinNT)
+ // continue;
+ } else {
+ if (PeekNamedPipe((HANDLE)h, 0, 0, 0, &res, 0)) {
+ if (1 /*res > 0*/) {
#ifdef SELECT1DEBUGWIN32
- printf("no wait l=%d ret this is a Pipe %x\n", res, fd);
-#endif
- RETURN (fd);
- }
+ printf("no wait l=%d ret this is a Pipe %x\n", res, fd);
+#endif
+ RETURN (fd);
+ }
#ifdef SELECT1DEBUGWIN32
- printf("readWait Handle %d this is a Pipe %x\n", i, fd);
-#endif
- continue;
- } else {
+ printf("readWait Handle %d this is a Pipe %x\n", i, fd);
+#endif
+ continue;
+ } else {
#ifdef SELECT2DEBUGWIN32
- printf("readWait Handle %d this is ??? %x\n", i, fd);
-#endif
- errno = EBADF;
- @global(LastErrorNumber) = __MKSMALLINT(errno);
- RETURN ( nil );
- }
- }
- }
- retArray[numHandles] = i;
- numHandles++;
- }
- }
+ printf("readWait Handle %d this is ??? %x\n", i, fd);
+#endif
+ errno = EBADF;
+ @global(LastErrorNumber) = __MKSMALLINT(errno);
+ RETURN ( nil );
+ }
+ }
+ }
+ retArray[numHandles] = i;
+ numHandles++;
+ }
+ }
}
if (__isNonNilObject(writeFdArray)) {
- if (! __isArray(writeFdArray)) {
- goto fail;
- }
- count = __arraySize(writeFdArray);
- for (i=0; (i<count) && (numHandles < MAXHANDLE);i++) {
- fd = __ArrayInstPtr(writeFdArray)->a_element[i];
- if (fd != nil) {
- if (__isExternalAddress(fd)) {
- hArray[numHandles] = _HANDLEVal(fd);
- } else {
- hArray[numHandles] = (HANDLE) _get_osfhandle (__intVal(fd));
- }
+ if (! __isArray(writeFdArray)) {
+ goto fail;
+ }
+ count = __arraySize(writeFdArray);
+ for (i=0; (i<count) && (numHandles < MAXHANDLE);i++) {
+ fd = __ArrayInstPtr(writeFdArray)->a_element[i];
+ if (fd != nil) {
+ if (__isExternalAddress(fd)) {
+ hArray[numHandles] = _HANDLEVal(fd);
+ } else {
+ hArray[numHandles] = (HANDLE) _get_osfhandle (__intVal(fd));
+ }
#ifdef SELECTDEBUGWIN32
- printf("select of writeFdArray %x\n",hArray[numHandles]);
-#endif
- retArray[numHandles] = i + 10000;
- numHandles++;
- }
- }
+ printf("select of writeFdArray %x\n",hArray[numHandles]);
+#endif
+ retArray[numHandles] = i + 10000;
+ numHandles++;
+ }
+ }
}
if (__isNonNilObject(exceptFdArray)) {
- if (! __isArray(exceptFdArray)) {
- goto fail;
- }
- count = __arraySize(exceptFdArray);
- for (i=0; (i<count) && (numHandles < MAXHANDLE);i++) {
- fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
- if (fd != nil) {
- if (__isExternalAddress(fd)) {
- hArray[numHandles] = _HANDLEVal(fd);
- } else {
- hArray[numHandles] = (HANDLE) _get_osfhandle (__intVal(fd));
- }
+ if (! __isArray(exceptFdArray)) {
+ goto fail;
+ }
+ count = __arraySize(exceptFdArray);
+ for (i=0; (i<count) && (numHandles < MAXHANDLE);i++) {
+ fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
+ if (fd != nil) {
+ if (__isExternalAddress(fd)) {
+ hArray[numHandles] = _HANDLEVal(fd);
+ } else {
+ hArray[numHandles] = (HANDLE) _get_osfhandle (__intVal(fd));
+ }
#ifdef SELECTDEBUGWIN32
- printf("select of exceptFdArray %x\n",hArray[numHandles]);
-#endif
- retArray[numHandles] = i + 20000;
- numHandles++;
- }
- }
+ printf("select of exceptFdArray %x\n",hArray[numHandles]);
+#endif
+ retArray[numHandles] = i + 20000;
+ numHandles++;
+ }
+ }
}
if (__isSmallInteger(millis)) {
- t = __intVal(millis);
+ t = __intVal(millis);
} else {
- t = INFINITE;
+ t = INFINITE;
}
if (numHandles) {
#ifdef SELECT3DEBUGWIN32
- printf("wait Handles = %d timeout = %d\n",numHandles,t);
-#endif
- res = __vmWait(numHandles, hArray, MAXHANDLE, t);
-
- if (res == WAIT_FAILED) {
+ printf("wait Handles = %d timeout = %d\n",numHandles,t);
+#endif
+ res = __vmWait(numHandles, hArray, MAXHANDLE, t);
+
+ if (res == WAIT_FAILED) {
#ifdef SELECT2DEBUGWIN32
- printf("- error %d; ret nil\n",GetLastError());
-#endif
- if (errno == EINTR) {
- errno = 0;
- @global(LastErrorNumber) = nil;
- } else {
- errno = EBADF;
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "OS [info]: select errno = %d\n", errno);
- }
- @global(LastErrorNumber) = __MKSMALLINT(errno);
- }
- RETURN ( nil );
- }
-
- if (res == WAIT_TIMEOUT) {
+ printf("- error %d; ret nil\n",GetLastError());
+#endif
+ if (errno == EINTR) {
+ errno = 0;
+ @global(LastErrorNumber) = nil;
+ } else {
+ errno = EBADF;
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "OS [info]: select errno = %d\n", errno);
+ }
+ @global(LastErrorNumber) = __MKSMALLINT(errno);
+ }
+ RETURN ( nil );
+ }
+
+ if (res == WAIT_TIMEOUT) {
#ifdef SELECT3DEBUGWIN32
- printf("- timeOut; ret nil\n");
-#endif
- goto polling;
- // @global(LastErrorNumber) = nil;
- // RETURN ( nil );
- }
-
- if ((res < 0) || (res >= numHandles)) {
+ printf("- timeOut; ret nil\n");
+#endif
+ goto polling;
+ // @global(LastErrorNumber) = nil;
+ // RETURN ( nil );
+ }
+
+ if ((res < 0) || (res >= numHandles)) {
#ifdef SELECTDEBUGWIN32
- printf("- res=%d error1 %d\n", res, GetLastError());
+ printf("- res=%d error1 %d\n", res, GetLastError());
#endif
- errno = 0;
- @global(LastErrorNumber) = nil;
- RETURN ( nil );
- }
-
- ret = res;
-
- if (ret < numHandles) {
- int fd = retArray[ret];
-
- @global(LastErrorNumber) = nil;
+ errno = 0;
+ @global(LastErrorNumber) = nil;
+ RETURN ( nil );
+ }
+
+ ret = res;
+
+ if (ret < numHandles) {
+ int fd = retArray[ret];
+
+ @global(LastErrorNumber) = nil;
#ifdef SELECTDEBUGWIN32
- if (ret) printf("wait Handles %d %d ret\n", ret, fd);
-#endif
- if (fd < 10000) {
- RETURN ( __ArrayInstPtr(readFdArray)->a_element[fd] );
- }
- if (fd < 20000) {
- RETURN ( __ArrayInstPtr(writeFdArray)->a_element[fd-10000] );
- }
- RETURN ( __ArrayInstPtr(exceptFdArray)->a_element[fd-20000] );
- }
- printf("wait Handles ret = %d error2 %d\n", ret, GetLastError());
- goto fail;
+ if (ret) printf("wait Handles %d %d ret\n", ret, fd);
+#endif
+ if (fd < 10000) {
+ RETURN ( __ArrayInstPtr(readFdArray)->a_element[fd] );
+ }
+ if (fd < 20000) {
+ RETURN ( __ArrayInstPtr(writeFdArray)->a_element[fd-10000] );
+ }
+ RETURN ( __ArrayInstPtr(exceptFdArray)->a_element[fd-20000] );
+ }
+ printf("wait Handles ret = %d error2 %d\n", ret, GetLastError());
+ goto fail;
} else {
#ifdef SELECTDEBUGWIN32
- printf("wait NoHandles timeout = %d\n",t);
-#endif
- res = __vmWait(0, hArray, MAXHANDLE, t);
+ printf("wait NoHandles timeout = %d\n",t);
+#endif
+ res = __vmWait(0, hArray, MAXHANDLE, t);
polling:
- if (__isNonNilObject(readFdArray)) {
- HANDLE h;
- if (! __isArray(readFdArray)) {
- goto fail;
- }
- count = __arraySize(readFdArray);
- for (i=0; (i<count);i++) {
- fd = __ArrayInstPtr(readFdArray)->a_element[i];
- if (fd != nil) {
- if (__isExternalAddress(fd)) {
- continue;
- } else {
- h = (HANDLE) _get_osfhandle (__intVal(fd));
-
- if (ioctlsocket((SOCKET)h, FIONREAD, &res)==0) {
- if (1 /*res > 0*/) {
- RETURN ( fd );
- }
- } else {
- if (PeekNamedPipe((HANDLE)h,0,0,0,&res,0)) {
- if (1 /*res > 0*/) {
- RETURN ( fd );
- } else {
- continue;
- }
- } else {
- if (t) {
- RETURN ( fd );
- }
- }
- }
- }
- }
- }
- }
- @global(LastErrorNumber) = nil;
- RETURN ( nil );
+ if (__isNonNilObject(readFdArray)) {
+ HANDLE h;
+ if (! __isArray(readFdArray)) {
+ goto fail;
+ }
+ count = __arraySize(readFdArray);
+ for (i=0; (i<count);i++) {
+ fd = __ArrayInstPtr(readFdArray)->a_element[i];
+ if (fd != nil) {
+ if (__isExternalAddress(fd)) {
+ continue;
+ } else {
+ h = (HANDLE) _get_osfhandle (__intVal(fd));
+
+ if (ioctlsocket((SOCKET)h, FIONREAD, &res)==0) {
+ if (1 /*res > 0*/) {
+ RETURN ( fd );
+ }
+ } else {
+ if (PeekNamedPipe((HANDLE)h,0,0,0,&res,0)) {
+ if (1 /*res > 0*/) {
+ RETURN ( fd );
+ } else {
+ continue;
+ }
+ } else {
+ if (t) {
+ RETURN ( fd );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ @global(LastErrorNumber) = nil;
+ RETURN ( nil );
}
fail: ;
@@ -7804,6 +7806,6 @@
!Win32OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.76 1999-08-11 17:33:20 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.77 1999-09-17 14:09:08 cg Exp $'
! !
Win32OperatingSystem initialize!