http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.bugs&article_id=14685 > On 2008年7月22日 09:50:06 -0400, shinichiro.h wrote: Hi D guys, The following program import std.stream; import std.cstream; import std.thread; class ReaderThread : Thread { override int run() { char[] line = din.readLine(); dout.writeLine(line); return 0; } } void main() { ReaderThread rt = new ReaderThread(); rt.start(); for (int i = 0; i < 100000; i++) { new Object; } rt.wait(); } works as intended on Windows (suppose a scenario in which a user may input a line after the for-loop): 1. Start ReaderThread 2. 100000 allocations 3. a user input a line 4. show the line and finish ReaderThread 5. the program finishes but doesn't work on Linux 1. Start ReaderThread 2. 100000 allocations 3. during the allocations, GC is invoked and SIGUSR1 is issued to stop the world 4. the SIGUSR1 makes read system call fail (errno=EINTR) 5. the program outputs empty line and finishes without waiting the user's input. this issue is serious when we are writing network applications (synchronous accept(2) or read(2) fail often). The following super short patch will fix the problem: --- /usr/local/dmd/src/phobos/std/thread.d 2008年04月28日 06:00:52.000000000 +0900 +++ thread.d 2008年07月22日 03:21:11.000000000 +0900 @@ -1044,6 +1044,7 @@ if (result) goto Lfail; sigact.sa_handler = &pauseHandler; + sigact.sa_flags = 0x10000000u /* SA_RESTART */; result = sigaction(SIGUSR1, &sigact, null); if (result) goto Lfail; you may want to put SA_RESTART in somewhere else (supposedly, std.c.linux.linux?) though. I believe tango doesn't have this problem since its Thread.d seems to set SA_RESTART. I hope this patch is accepted in near future. I'm using dmd-2.014.
Fixed dmd 1.034 and 2.018
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル