[#13434] irb message typo — Kazuhiro NISHIYAMA <zn@...>
typoだと思います。
[#13455] ext/extmk.rb.in — Kazuhiro NISHIYAMA <zn@...>
ext/extmk.rb.inですが、'w'でopenするのならreadable?ではなく
わたなべです。
[#13463] [BUG?] mutex_m.rb — akira yamada / やまだあきら <akira@...>
まつもと ゆきひろです
[#13479] [BUG] Segmentation fault — Kazuhiro NISHIYAMA <zn@...>
文字列操作しているところで[BUG] Segmentation faultとでて
まつもと ゆきひろです
In <991811793.511554.930.nullmailer@ev.netlab.zetabits.com>
まつもと ゆきひろです
[#13486] drive letter on mingw32 — nobu.nakada@...
なかだです。
まつもと ゆきひろです
こんにちは、なかむら(う)です。
[#13493] yield *[[]] — Tanaka Akira <akr@...17n.org>
しばらく前に、yield *[[]] の挙動に関して bug report をして、まつもとさ
なかだです。
In article <200106071409.XAA21101@sharui.nakada.kanuma.tochigi.jp>,
まつもと ゆきひろです
In article <991988462.179562.20598.nullmailer@ev.netlab.zetabits.com>,
まつもと ゆきひろです
In article <992009406.425405.24078.nullmailer@ev.netlab.zetabits.com>,
まつもと ゆきひろです
asgn.rb を読んでみましたが... なんというか nil.to_a が [] であることを
まつもと ゆきひろです
In article <992022213.746115.25347.nullmailer@ev.netlab.zetabits.com>,
前田です。
Shugo Maedaさんの<87lmn336s3.wl@localhost.netlab.jp>から
前田です。
Shugo Maedaさんの<87hexr316u.wl@localhost.netlab.jp>から
前田です。
まつもと ゆきひろです
前田です。
In article <m38zj242y9.wl@localhost.localdomain>,
原です。
In article <4.3.2-J.20010612154813.02c89a70@blade.nagaokaut.ac.jp>,
原です。
In article <4.3.2-J.20010612185543.00c8b988@blade.nagaokaut.ac.jp>,
原です。
まつもと ゆきひろです
原です。
まつもと ゆきひろです
原です。
まつもと ゆきひろです
まつもと ゆきひろです
In article <992410104.066682.22743.nullmailer@ev.netlab.zetabits.com>,
In article <hvor8wo501g.fsf@flux.etl.go.jp>,
まつもと ゆきひろです
In article <992533086.935976.4066.nullmailer@ev.netlab.zetabits.com>,
まつもと ゆきひろです
まつもと ゆきひろです
まつもと ゆきひろです
まつもと ゆきひろです
けいじゅ@日本ラショナルソフトウェアです.
金光です。
まつもと ゆきひろです
金光です。
前田です。
けいじゅ@日本ラショナルソフトウェアです.
金光です。(^_^)
[#13535] File::fnmatch to go — "Akinori MUSHA" <knu@...>
そろそろ File::fnmatch の件を決着させたいので最終提案です。
[#13564] Dir::open(){} — keiju@... (Keiju ISHITSUKA)
けいじゅ@日本ラショナルソフトウェアです.
[#13624] Forward: Re: [ruby-talk:16677] Re: Problem running irb with Ruby 1.6.4 under FreeBSD 4.0 — matz@... (Yukihiro Matsumoto)
まつもと ゆきひろです
わたなべです。
[#13626] Syncronizing the 1.6 libraries with the 1.7 ones — "Akinori MUSHA" <knu@...>
標準添付ライブラリの 1.6 と 1.7 での違いを調べてみたのですが、
[#13631] 超漢字 ruby が落ちる — "TOYOFUKU Chikanobu" <toyofuku@...>
豊福です。
[#13650] Re: [ruby-ext:01803] Re: Ruby/SDL on PS2 LinuxKit — WATANABE Hirofumi <eban@...>
わたなべです。
まつもと ゆきひろです
まつもと ゆきひろです
なかだです。
なかだです。
まつもと ゆきひろです
なかだです。
まつもと ゆきひろです
なかだです。
こんにちは、なかむら(う)です。
まつもと ゆきひろです
なかだです。
なかだです。
まつもと ゆきひろです
なかだです。
まつもと ゆきひろです
まつもと ゆきひろです
まつもと ゆきひろです
なかだです。
まつもと ゆきひろです
なかだです。
まつもと ゆきひろです
なかだです。
有馬です。
なかだです。
有馬です。
In message <200107301156.AA00175@fit0298.fitec.co.jp>
[#13652] very long array and GC. — Tanaka Akira <akr@...17n.org>
ふと、とても長い配列を使う機会があったのですが、なんとなく遅いことに気がつきました。
Tanaka Akiraさんの<hvoithjwz23.fsf@flux.etl.go.jp>から
In article <200106260640.PAA12913@zeus.sofnec.co.jp>,
まつもと ゆきひろです
In article <993540668.285220.13545.nullmailer@ev.netlab.zetabits.com>,
[#13666] net/http.rb warnings — nobu.nakada@...
なかだです。
あおきです。
なかだです。
[#13668] ruby_m17n make error — TAKAHASHI Masayoshi <maki@...>
高橋征義です。
まつもと ゆきひろです
高橋征義です。
まつもと ゆきひろです
高橋征義です。
豊福です。
[#13672] irb/ruby-lex.rb — GOTO Kentaro <gotoken@...>
引数の数が間違ってるのは確かですが、これで正しいのか自信はあ
[#13705] eval(code, true, filename) — Shugo Maeda <shugo@...>
前田です。
まつもと ゆきひろです
前田です。
Shugo Maedaさんの<wkithdwg3r.wl@STUDLY.priv.netlab.jp>から
[ruby-dev:13442] Re: mswin32/ming32 system patch (experimental)
こんにちは、なかむら(う)です。
At Fri, 1 Jun 2001 23:29:21 +0900, nobu.nakada@nifty.ne.jp wrote in
'[ruby-dev:13435] Re: mswin32/ming32 system patch (experimental)'
> CreateProcess() 使う方向でいいんじゃないでしょうか。ただ、子
> プロセスの終了待ちは rb_f_system() の方でやった方がいいような
> 気がしなくもありません。それと、このパッチだと RUBYSHELL や
> COMSPEC を使うときには、やはりスレッドが止まってしまうように思
> えるのですが。
前者の方は、まだ考慮中です。process.cの中をそれなりの
規模でいじらないといけなさそうで...
後者の方は、こんなんでどうでしょう?
ついでにmypopen()の方も触ってます。
# NtHasRedirection()の中で'|'を扱ってないのはなぜ???
CVS HEADからの差分です。
diff -p2ur current/process.c mytree/process.c
--- current/process.c Tue May 22 23:34:12 2001
+++ mytree/process.c Fri Jun 1 16:41:50 2001
@@ -228,5 +228,5 @@ static st_table *pid_tbl;
#endif
-static int
+int
rb_waitpid(pid, flags, st)
int pid;
diff -p2ur current/win32/win32.c mytree/win32/win32.c
--- current/win32/win32.c Sat May 12 15:43:28 2001
+++ mytree/win32/win32.c Fri Jun 1 17:43:26 2001
@@ -73,4 +73,5 @@ extern char **environ;
#endif
+exec_and_nowait(char*, SECURITY_ATTRIBUTES*, HANDLE, HANDLE);
static bool NtHasRedirection (char *);
static int valid_filename(char *s);
@@ -574,13 +575,8 @@ mypopen (char *cmd, char *mode)
{
int p[2];
+ int pid;
BOOL fRet;
HANDLE hInFile, hOutFile;
- LPCSTR lpApplicationName = NULL;
- LPTSTR lpCommandLine;
- LPTSTR lpCmd2 = NULL;
- DWORD dwCreationFlags;
- STARTUPINFO aStartupInfo;
- PROCESS_INFORMATION aProcessInformation;
SECURITY_ATTRIBUTES sa;
int fd;
@@ -596,44 +592,11 @@ mypopen (char *cmd, char *mode)
}
- memset(&aStartupInfo, 0, sizeof (STARTUPINFO));
- memset(&aProcessInformation, 0, sizeof (PROCESS_INFORMATION));
- aStartupInfo.cb = sizeof (STARTUPINFO);
- aStartupInfo.dwFlags = STARTF_USESTDHANDLES;
-
if (reading) {
- aStartupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
- aStartupInfo.hStdOutput = hOutFile;
+ pid = exec_and_nowait(cmd, &sa, NULL, hOutFile);
}
else {
- aStartupInfo.hStdInput = hInFile;
- aStartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
- }
- aStartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
-
- dwCreationFlags = (NORMAL_PRIORITY_CLASS);
-
- lpCommandLine = cmd;
- if (NtHasRedirection(cmd) || isInternalCmd(cmd)) {
- lpApplicationName = getenv("COMSPEC");
- lpCmd2 = xmalloc(strlen(lpApplicationName) + 1 + strlen(cmd) + sizeof (" /c "));
- sprintf(lpCmd2, "%s %s%s", lpApplicationName, " /c ", cmd);
- lpCommandLine = lpCmd2;
+ pid = exec_and_nowait(cmd, &sa, hInFile, NULL);
}
- fRet = CreateProcess(lpApplicationName, lpCommandLine, &sa, &sa,
- sa.bInheritHandle, dwCreationFlags, NULL, NULL, &aStartupInfo, &aProcessInformation);
- errno = GetLastError();
-
- if (lpCmd2)
- free(lpCmd2);
-
- if (!fRet) {
- CloseHandle(hInFile);
- CloseHandle(hOutFile);
- return NULL;
- }
-
- CloseHandle(aProcessInformation.hThread);
-
if (reading) {
fd = _open_osfhandle((long)hInFile, (_O_RDONLY | pipemode));
@@ -647,5 +610,5 @@ mypopen (char *cmd, char *mode)
if (fd == -1) {
CloseHandle(reading ? hInFile : hOutFile);
- CloseHandle(aProcessInformation.hProcess);
+ CloseHandle((HANDLE)pid);
rb_sys_fail("mypopen: _open_osfhandle");
}
@@ -653,5 +616,5 @@ mypopen (char *cmd, char *mode)
if ((fp = (FILE *) fdopen(fd, mode)) == NULL) {
_close(fd);
- CloseHandle(aProcessInformation.hProcess);
+ CloseHandle((HANDLE)pid);
rb_sys_fail("mypopen: fdopen");
}
@@ -659,5 +622,5 @@ mypopen (char *cmd, char *mode)
MyPopenRecord[slot].inuse = TRUE;
MyPopenRecord[slot].pipe = fp;
- MyPopenRecord[slot].pid = (int)aProcessInformation.hProcess;
+ MyPopenRecord[slot].pid = pid;
return fp;
}
@@ -665,9 +628,12 @@ mypopen (char *cmd, char *mode)
}
+int rb_waitpid(int, int, int*);
+
int
mypclose(FILE *fp)
{
int i;
- DWORD exitcode;
+ int status = -1;
+ int ret;
Sleep(100);
@@ -683,33 +649,16 @@ mypclose(FILE *fp)
// get the return status of the process
//
-
-#if 0
- if (_cwait(&exitcode, MyPopenRecord[i].pid, WAIT_CHILD) == -1) {
- if (errno == ECHILD) {
- fprintf(stderr, "mypclose: nosuch child as pid %x\n",
- MyPopenRecord[i].pid);
+ for (;;) {
+ ret = rb_waitpid(MyPopenRecord[i].pid, WNOHANG, &status);
+ if (ret > 0 || (ret == -1 && errno != EINTR)) {
+ // process is done, or die by some error.
+ break;
}
+
+ // process is still active
+ Sleep(100);
+ TerminateProcess((HANDLE)MyPopenRecord[i].pid, 0);
}
-#else
- for (;;) {
- if (GetExitCodeProcess((HANDLE)MyPopenRecord[i].pid, &exitcode)) {
- if (exitcode == STILL_ACTIVE) {
- //printf("Process is Active.\n");
- Sleep(100);
- TerminateProcess((HANDLE)MyPopenRecord[i].pid, 0); // ugly...
- continue;
- }
- else if (exitcode == 0) {
- //printf("done.\n");
- break;
- }
- else {
- //printf("never.\n");
- break;
- }
- }
- }
- CloseHandle((HANDLE)MyPopenRecord[i].pid);
-#endif
+ CloseHandle((HANDLE)MyPopenRecord[i].pid);
//
@@ -728,5 +677,5 @@ mypclose(FILE *fp)
MyPopenRecord[i].pid = 0;
- return (int)((exitcode & 0xff) << 8);
+ return status;
}
#endif
@@ -741,103 +690,100 @@ typedef char* CHARP;
*/
-int
-do_spawn(cmd)
-char *cmd;
+static int
+exec_and_nowait(char *cmd, SECURITY_ATTRIBUTES *psa, HANDLE hInput, HANDLE hOutput)
{
- register char **a;
- register char *s;
- char **argv;
- int status = -1;
- char *shell, *cmd2;
- int mode = NtSyncProcess ? P_WAIT : P_NOWAIT;
- char quote;
- char *exec;
-
- /* save an extra exec if possible */
- if ((shell = getenv("RUBYSHELL")) != 0) {
- if (NtHasRedirection(cmd)) {
- int i;
- char *p;
- char *argv[4];
- char *cmdline = ALLOC_N(char, (strlen(cmd) * 2 + 1));
-
- p=cmdline;
- *p++ = '"';
- for (s=cmd; *s;) {
- if (*s == '"')
- *p++ = '\\'; /* Escape d-quote */
- *p++ = *s++;
- }
- *p++ = '"';
- *p = '\0';
+ BOOL fRet;
+ LPCSTR lpApplicationName = NULL;
+ LPTSTR lpCommandLine;
+ LPTSTR lpCmd2 = NULL;
+ DWORD dwCreationFlags;
+ STARTUPINFO aStartupInfo;
+ PROCESS_INFORMATION aProcessInformation;
+ SECURITY_ATTRIBUTES sa;
+ char *shell;
+
+ if (!psa) {
+ sa.nLength = sizeof (SECURITY_ATTRIBUTES);
+ sa.lpSecurityDescriptor = NULL;
+ sa.bInheritHandle = TRUE;
+ psa = &sa;
+ }
+
+ memset(&aStartupInfo, 0, sizeof (STARTUPINFO));
+ memset(&aProcessInformation, 0, sizeof (PROCESS_INFORMATION));
+ aStartupInfo.cb = sizeof (STARTUPINFO);
+ aStartupInfo.dwFlags = STARTF_USESTDHANDLES;
+ if (hInput) {
+ aStartupInfo.hStdInput = hInput;
+ }
+ else {
+ aStartupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
+ }
+ if (hOutput) {
+ aStartupInfo.hStdOutput = hOutput;
+ }
+ else {
+ aStartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
+ }
+ aStartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
- /* fprintf(stderr, "do_spawn: %s %s\n", shell, cmdline); */
- argv[0] = shell;
- argv[1] = "-c";
- argv[2] = cmdline;
- argv[4] = NULL;
- status = spawnvpe(mode, argv[0], argv, environ);
- /* return spawnle(mode, shell, shell, "-c", cmd, (char*)0, environ); */
- free(cmdline);
- return (int)((status & 0xff) << 8);
- }
- }
- else if ((shell = getenv("COMSPEC")) != 0) {
- if (NtHasRedirection(cmd) /* || isInternalCmd(cmd) */) {
- status = spawnle(mode, shell, shell, "/c", cmd, (char*)0, environ);
- return (int)((status & 0xff) << 8);
- }
+ dwCreationFlags = (NORMAL_PRIORITY_CLASS);
+
+ lpCommandLine = cmd;
+
+ if ((shell = getenv("RUBY_SHELL")) && NtHasRedirection(cmd)) {
+ lpApplicationName = shell;
+ lpCmd2 = ALLOC_N(char, strlen(lpApplicationName) + 1 + strlen(cmd) + sizeof (" -c "));
+ sprintf(lpCmd2, "%s %s%s", lpApplicationName, " -c ", cmd);
+ lpCommandLine = lpCmd2;
+ }
+ else if ((shell = getenv("COMSPEC")) &&
+ (NtHasRedirection(cmd) || isInternalCmd(cmd))) {
+ lpApplicationName = shell;
+ lpCmd2 = ALLOC_N(char, strlen(lpApplicationName) + 1 + strlen(cmd) + sizeof (" /c "));
+ sprintf(lpCmd2, "%s %s%s", lpApplicationName, " /c ", cmd);
+ lpCommandLine = lpCmd2;
}
- argv = ALLOC_N(CHARP, (strlen(cmd) / 2 + 2));
- cmd2 = ALLOC_N(char, (strlen(cmd) + 1));
- strcpy(cmd2, cmd);
- a = argv;
- for (s = cmd2; *s;) {
- while (*s && ISSPACE(*s)) s++;
- if (*s == '"') {
- quote = *s;
- *(a++) = s++;
- while (*s) {
- if (*s == '\\' && *(s + 1) == quote) {
- memmove(s, s + 1, strlen(s) + 1);
- s++;
- }
- else if (*s == quote) {
- s++;
- break;
- }
- s++;
- }
- }
- else if (*s) {
- *(a++) = s;
- while (*s && !ISSPACE(*s)) s++;
- }
- if (*s)
- *s++ = '\0';
- }
- *a = NULL;
- exec = NULL;
- if (argv[0]) {
- exec = ALLOC_N(char, (strlen(argv[0]) + 1));
- if (argv[0][0] == '"' && argv[0][strlen(argv[0]) - 1] == '"') {
- strcpy(exec, &argv[0][1]);
- exec[strlen(exec) - 1] = '\0';
- }
- else {
- strcpy(exec, argv[0]);
+ RUBY_CRITICAL({
+ fRet = CreateProcess(lpApplicationName, lpCommandLine, &sa, &sa,
+ sa.bInheritHandle, dwCreationFlags, NULL, NULL,
+ &aStartupInfo, &aProcessInformation);
+ errno = GetLastError();
+ });
+ if (lpCmd2)
+ free(lpCmd2);
+
+ if (!fRet) {
+ if (hInput) {
+ CloseHandle(hInput);
}
- if ((status = spawnvpe(mode, exec, argv, environ)) == -1) {
- free(exec);
- free(argv);
- free(cmd2);
- return -1;
+ if (hOutput) {
+ CloseHandle(hOutput);
}
+ rb_sys_fail("exec_and_wait: CreateProcess");
}
- free(exec);
- free(cmd2);
- free(argv);
- return (int)((status & 0xff) << 8);
+
+ CloseHandle(aProcessInformation.hThread);
+
+ return (int)aProcessInformation.hProcess;
+}
+
+int
+do_spawn(cmd)
+char *cmd;
+{
+ int pid;
+ int status;
+ int ret;
+
+ pid = exec_and_nowait(cmd, NULL, NULL, NULL);
+
+ do {
+ ret = rb_waitpid(pid, 0, &status);
+ } while (ret == -1 && errno == EINTR);
+ CloseHandle((HANDLE)pid);
+
+ return status;
}
@@ -1030,9 +976,9 @@ NtCmdGlob (NtCmdLineElement *patt)
static bool
-NtHasRedirection (char *cmd)
+NtHasRedirection (const char *cmd)
{
int inquote = 0;
char quote = '\0';
- char *ptr ;
+ const char *ptr ;
//
@@ -1061,4 +1007,5 @@ NtHasRedirection (char *cmd)
case '>':
case '<':
+ case '|':
if (!inquote)
それでは。
--
U.Nakamura <usa@osb.att.ne.jp>