[#8824] [REQ] Integer#{hex,dec,oct,bin}, String#bin — gotoken@... (GOTO Kentaro)

ごとけんです

38 messages 2000/01/05
[#8839] Re: [REQ] Integer#{hex,dec,oct,bin}, String#bin — matz@... (Yukihiro Matsumoto) 2000/01/06

まつもと ゆきひろです

[#8842] Re: [REQ] Integer#{hex,dec,oct,bin}, String#bin — gotoken@... (GOTO Kentaro) 2000/01/06

ごとけんです

[#8843] Re: [REQ] Integer#{hex,dec,oct,bin}, String#bin — matz@... (Yukihiro Matsumoto) 2000/01/06

まつもと ゆきひろです

[#8844] Re: [REQ] Integer#{hex,dec,oct,bin}, String#bin — gotoken@... (GOTO Kentaro) 2000/01/06

ごとけんです

[#8846] Re: [REQ] Integer#{hex,dec,oct,bin}, String#bin — matz@... (Yukihiro Matsumoto) 2000/01/06

まつもと ゆきひろです

[#8847] Re: [REQ] Integer#{hex,dec,oct,bin}, String#bin — gotoken@... (GOTO Kentaro) 2000/01/06

ごとけんです

[#8893] Re: [ruby-list:20142] Re: Range expansion? — Akinori MUSHA aka knu <knu@...>

 knuです。ruby-listから舞台を移しました。

13 messages 2000/01/09

[#8980] 1.4.3 patch for near-future *BSD IPv6 support — Jun-ichiro itojun Hagino <itojun@...>

近い将来の{Net,Free,Open}BSDにはKAME IPv6 stackが統合されています。

17 messages 2000/01/20
[#8981] Re: 1.4.3 patch for near-future *BSD IPv6 support — Jun-ichiro itojun Hagino <itojun@...> 2000/01/20

> それから、

[ruby-dev:8858] [PATCH] 2000/1/5 ruby_1_4 commit

From: Katsuyuki Komatsu <komatsu@...>
Date: 2000-01-07 00:37:01 UTC
List: ruby-dev #8858
小松です。

ruby_1_4の2000/1/5のコミットで、ChangeLogには、
	* win32/win32.c (mypopen): raise catchable error instead of rb_fatal.
	* win32/win32.c (mypclose): fix process handle laek.
	* io.c (pipe_open): check for `fptr->f == NULL'.
があるのに実際には取り込まれていないようです。
パッチ付けます。

diff -rup ruby-1.4.4.dist/io.c ruby-1.4.4/io.c
--- ruby-1.4.4.dist/io.c	Wed Jan  5 13:41:07 2000
+++ ruby-1.4.4/io.c	Wed Jan  5 16:37:32 2000
@@ -1451,7 +1451,8 @@ pipe_open(pname, mode)
 	pipe_add_fptr(fptr);
 	if (modef & FMODE_READABLE) fptr->f  = f;
 	if (modef & FMODE_WRITABLE) {
-	    fptr->f2 = f;
+	    if (fptr->f) fptr->f2 = f;
+	    else fptr->f = f;
 	    rb_io_synchronized(fptr);
 	}
 	return (VALUE)port;
diff -rup ruby-1.4.4.dist/win32/win32.c ruby-1.4.4/win32/win32.c
--- ruby-1.4.4.dist/win32/win32.c	Wed Jan  5 13:41:20 2000
+++ ruby-1.4.4/win32/win32.c	Tue Dec 28 01:57:23 1999
@@ -229,7 +229,6 @@ char *getlogin()
 struct {
     int inuse;
     int pid;
-    HANDLE oshandle;
     FILE *pipe;
 } MyPopenRecord[MYPOPENSIZE];
 
@@ -509,23 +508,11 @@ mypopen (char *cmd, char *mode) 
 		sa.lpSecurityDescriptor = NULL;
 		sa.bInheritHandle       = TRUE;
 
-		if (!reading) {
-        	FILE *fp;
-
-			fp = (_popen)(cmd, mode);
-
-			MyPopenRecord[slot].inuse = TRUE;
-			MyPopenRecord[slot].pipe = fp;
-			MyPopenRecord[slot].pid = -1;
-
-			if (!fp)
-                        rb_fatal("cannot open pipe \"%s\" (%s)", cmd, strerror(errno));
-				return fp;
-		}
-
 		fRet = CreatePipe(&hInFile, &hOutFile, &sa, 2048L);
-		if (!fRet)
-                        rb_fatal("cannot open pipe \"%s\" (%s)", cmd, strerror(errno));
+		if (!fRet) {
+			errno = GetLastError();
+			rb_sys_fail("mypopen: CreatePipe");
+		}
 
 		memset(&aStartupInfo, 0, sizeof (STARTUPINFO));
 		memset(&aProcessInformation, 0, sizeof (PROCESS_INFORMATION));
@@ -547,46 +534,50 @@ mypopen (char *cmd, char *mode) 
 		lpCommandLine = cmd;
 		if (NtHasRedirection(cmd) || isInternalCmd(cmd)) {
 		  lpApplicationName = getenv("COMSPEC");
-		  lpCmd2 = malloc(strlen(lpApplicationName) + 1 + strlen(cmd) + sizeof (" /c "));
-		  if (lpCmd2 == NULL)
-                     rb_fatal("Mypopen: malloc failed");
+		  lpCmd2 = xmalloc(strlen(lpApplicationName) + 1 + strlen(cmd) + sizeof (" /c "));
 		  sprintf(lpCmd2, "%s %s%s", lpApplicationName, " /c ", cmd);
 		  lpCommandLine = lpCmd2;
 		}
 
 		fRet = CreateProcess(lpApplicationName, lpCommandLine, &sa, &sa,
 			sa.bInheritHandle, dwCreationFlags, NULL, NULL, &aStartupInfo, &aProcessInformation);
+		errno = GetLastError();
+
+		if (lpCmd2)
+			free(lpCmd2);
+
+		CloseHandle(aProcessInformation.hThread);
 
 		if (!fRet) {
 			CloseHandle(hInFile);
 			CloseHandle(hOutFile);
-                        rb_fatal("cannot fork for \"%s\" (%s)", cmd, strerror(errno));
+			CloseHandle(aProcessInformation.hProcess);
+			return NULL;
 		}
 
-		CloseHandle(aProcessInformation.hThread);
-
 		if (reading) {
 			fd = _open_osfhandle((long)hInFile,  (_O_RDONLY | pipemode));
 			CloseHandle(hOutFile);
 		}
 		else {
-		    fd = _open_osfhandle((long)hOutFile, (_O_WRONLY | pipemode));
+			fd = _open_osfhandle((long)hOutFile, (_O_WRONLY | pipemode));
 			CloseHandle(hInFile);
 		}
 
-		if (fd == -1) 
-                  rb_fatal("cannot open pipe \"%s\" (%s)", cmd, strerror(errno));
-
-
-		if ((fp = (FILE *) fdopen(fd, mode)) == NULL)
-			return NULL;
+		if (fd == -1) {
+			CloseHandle(reading ? hInFile : hOutFile);
+			CloseHandle(aProcessInformation.hProcess);
+			rb_sys_fail("mypopen: _open_osfhandle");
+		}
 
-		if (lpCmd2)
-			free(lpCmd2);
+		if ((fp = (FILE *) fdopen(fd, mode)) == NULL) {
+			_close(fd);
+			CloseHandle(aProcessInformation.hProcess);
+			rb_sys_fail("mypopen: fdopen");
+		}
 
 		MyPopenRecord[slot].inuse = TRUE;
 		MyPopenRecord[slot].pipe  = fp;
-		MyPopenRecord[slot].oshandle = (reading ? hInFile : hOutFile);
 		MyPopenRecord[slot].pid   = (int)aProcessInformation.hProcess;
 		return fp;
     }
@@ -638,14 +629,13 @@ mypclose(FILE *fp)
 			}
 		}
 	}
+	CloseHandle((HANDLE)MyPopenRecord[i].pid);
 #endif
 
-
     //
     // close the pipe
     //
-    // Closehandle() is done by fclose().
-    //CloseHandle(MyPopenRecord[i].oshandle);
+
     fflush(fp);
     fclose(fp);
 

--
小松克行 / Katsuyuki Komatsu <komatsu@sarion.co.jp>

In This Thread

Prev Next