[#8468] require で SEGV — ruby <g96p0935@...>
西本です。
[#8469] [PATCH] -s command line option — nobu.nakada@...
なかだです。
[#8507] mode_t in file.c — Katsuyuki Komatsu <komatsu@...>
小松です。
[#8530] Enumerable and rand — Koretsugu Daigoro <tmmcross@...>
これつぐです。
まつもと ゆきひろです
これつぐです。
まつもと ゆきひろです
原です。
まつもと ゆきひろです
原です。
ごとけんです
これつぐです。
[#8565] interface declaretion — "Dai.K." <MAP2303@...>
[#8581] Re: [ruby-list:19228] Ruby 1.4.3 — Katsuyuki Komatsu <komatsu@...>
小松です。
まつもと ゆきひろです
えぐち@エスアンドイー です。
小松です。
まつもと ゆきひろです
小松です。
[#8622] Win32API (Re: Ruby 1.4.3 binaries for Cygwin and DJGPP) — WATANABE Hirofumi <Hirofumi.Watanabe@...>
わたなべです.
有馬@FITECです。
よしだです
[#8623] [BUG?] core dump `ruby -r debug' — IWAMURO Motonori <iwa@...>
岩室@富士通です。
[#8635] slow gsub — WATANABE Hirofumi <Hirofumi.Watanabe@...>
わたなべです.
[#8645] urllib and httplib — TAKAHASHI Masayoshi <maki@...>
高橋征義です。
なひです.
高橋征義です。
なひです.
まつもと ゆきひろです
なひです.
青山です。
なひです.
高橋征義です。
まつもと ゆきひろです
高橋征義です。
なひです.
西@九大です。
なかだです。
あおきです。
[#8650] [PATCH] Ruby/Tk — Koji Arai <JCA02266@...>
新井です。
新井です。
新井です。
新井です。
永井@知能.九工大です.
新井です。
永井@知能.九工大です.
新井です。
新井です。
[#8665] [mswin32] STDERR does not work during `_function. — "NAKAMURA, Hiroshi" <nakahiro@...>
なひです.
金子です。
金子です。
[#8667] make symlinks around libruby.so in instruby.rb — akira yamada / やまだあきら <akira@...>
[#8692] [win] dir name — KANEKO Naoshi <wbs01621@...>
金子です。
小田@QNES です。
えぐち@エスアンドイー です。
小田@QNES です。
えぐち@エスアンドイー です。
なかだです。
小田@QNES です。
えぐち@エスアンドイー です。
小田@QNES です。
[#8705] [mswin32] 100% CPU usage when use sleep — Katsuyuki Komatsu <komatsu@...>
小松です。
まつもと ゆきひろです
小松です。
[#8722] [mswin32] Win32API — KANEKO Naoshi <wbs01621@...>
金子です。
小松です。
まつもと ゆきひろです
[#8741] Re: [ruby-list:19945] Re: array + empty string — Wakou Aoyama <wakou@...>
青山です。
まつもと ゆきひろです
青山です。
まつもと ゆきひろです
ごとけんです
まつもと ゆきひろです
なかだです。
まつもと ゆきひろです
[#8742] [REQ] Array#each{|a,b,...|}, Array#shift/pop(num) — Kazunori NISHI <kazunori@...>
西@九大です。
まつもと ゆきひろです
西@九大です。
まつもと ゆきひろです
西@九大です。
まつもと ゆきひろです
えぐち@エスアンドイー です。
西@九大です。
あおきです。議論も好き。
西@九大です。
あおきです。
まつもと ゆきひろです
有馬です。
knuです。
まつもと ゆきひろです
これつぐです。
knuです。
まつもと ゆきひろです
あおきです。
まつもと ゆきひろです
In message "[ruby-dev:8792] Re: [REQ] Array#each{|a,b,...|}, Array#shift/pop(num)"
まつもと ゆきひろです
ごとけんです
ごとけんです
なかだです。
ごとけんです
[ruby-dev:8728] Re: [mswin32] STDERR does not work during `_function.
小松です。
In the message of [ruby-dev:8716] Re: [mswin32] STDERR does not work during `_function.
on 1999/12/24 17:10:30 KIMURA Koichi <kimura@sqa.canon.co.jp> wrote:
|>元からですが、Processハンドルがリークしています。
|
|あ痛、お手数かけます。
|
|>あと、エラー時のCloseHandle()の処理とfree()の処理が不十分。
|># これも元からかな?
|
|多分そうです。試行錯誤の名残といえば名残ですが…
あと、たとえば、CreateProcess()でコマンドが見つからなくて失敗した
場合など、rb_fatal()は強すぎると思います。
また、malloc()はxmalloc()に変更しました。
ということで、こんなところかな?
# ts=8 sw=4にしたいという誘惑はなんとか我慢しました……
--- io.c.dist Tue Dec 14 15:50:38 1999
+++ io.c Fri Dec 24 15:11:15 1999
@@ -1449,5 +1449,6 @@ pipe_open(pname, mode)
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);
}
--- win32/win32.c.dist Tue Nov 9 12:57:28 1999
+++ win32/win32.c Sun Dec 26 23:15:13 1999
@@ -230,5 +230,4 @@ struct {
int inuse;
int pid;
- HANDLE oshandle;
FILE *pipe;
} MyPopenRecord[MYPOPENSIZE];
@@ -496,5 +495,5 @@ mypopen (char *cmd, char *mode)
BOOL fRet;
- HANDLE hInFile, hOutFile, hStdin, hStdout;
+ HANDLE hInFile, hOutFile;
LPCSTR lpApplicationName = NULL;
LPTSTR lpCommandLine;
@@ -510,21 +509,9 @@ mypopen (char *cmd, char *mode)
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));
@@ -534,33 +521,12 @@ mypopen (char *cmd, char *mode)
if (reading) {
- aStartupInfo.hStdInput = GetStdHandle(STD_OUTPUT_HANDLE);//hStdin;
- aStartupInfo.hStdError = INVALID_HANDLE_VALUE;
- //for save
- DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_OUTPUT_HANDLE),
- GetCurrentProcess(), &hStdout,
- 0, FALSE, DUPLICATE_SAME_ACCESS
- );
- //for redirect
- DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_INPUT_HANDLE),
- GetCurrentProcess(), &hStdin,
- 0, TRUE, DUPLICATE_SAME_ACCESS
- );
+ aStartupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
aStartupInfo.hStdOutput = hOutFile;
}
else {
- aStartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); //hStdout;
- aStartupInfo.hStdError = INVALID_HANDLE_VALUE;
- // for save
- DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_INPUT_HANDLE),
- GetCurrentProcess(), &hStdin,
- 0, FALSE, DUPLICATE_SAME_ACCESS
- );
- //for redirect
- DuplicateHandle(GetCurrentProcess(), GetStdHandle(STD_OUTPUT_HANDLE),
- GetCurrentProcess(), &hStdout,
- 0, TRUE, DUPLICATE_SAME_ACCESS
- );
- aStartupInfo.hStdInput = hInFile;
+ aStartupInfo.hStdInput = hInFile;
+ aStartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
}
+ aStartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
dwCreationFlags = (NORMAL_PRIORITY_CLASS);
@@ -569,7 +535,5 @@ mypopen (char *cmd, char *mode)
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;
@@ -578,47 +542,41 @@ mypopen (char *cmd, char *mode)
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) {
- HANDLE hDummy;
-
fd = _open_osfhandle((long)hInFile, (_O_RDONLY | pipemode));
CloseHandle(hOutFile);
- DuplicateHandle(GetCurrentProcess(), hStdout,
- GetCurrentProcess(), &hDummy,
- 0, TRUE, (DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE)
- );
}
else {
- HANDLE hDummy;
-
- fd = _open_osfhandle((long)hOutFile, (_O_WRONLY | pipemode));
+ fd = _open_osfhandle((long)hOutFile, (_O_WRONLY | pipemode));
CloseHandle(hInFile);
- DuplicateHandle(GetCurrentProcess(), hStdin,
- GetCurrentProcess(), &hDummy,
- 0, TRUE, (DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE)
- );
}
- 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;
@@ -672,12 +630,11 @@ 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>