Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!princeton!newross!dynamic.Princeton.EDU!nr From: nr@Princeton.EDU (Norman Ramsey) Newsgroups: comp.lang.modula3 Subject: help wanted with Thread.Alert Message-ID: <1991Apr4.015610.13835@newross.Princeton.EDU> Date: 4 Apr 91 01:56:10 GMT Sender: news@newross.Princeton.EDU (USENET News System) Organization: Princeton University, Dept. of Computer Science Lines: 53 Originator: nr@dynamic.Princeton.EDU I don't understand why my thread isn't raising Thread.Alerted in the following program: MODULE Alert EXPORTS Main; IMPORT Rd, Wr, Thread, Fmt; FROM Stdio IMPORT stdin, stdout; PROCEDURE Copy(cl:Thread.Closure):REFANY RAISES {} = VAR result := NEW(REF INTEGER); BEGIN result^ := 0; TRY LOOP WITH line = Rd.GetLine(stdin) DO INC(result^); Wr.PutText(stdout,Fmt.F("line is `%s\'\n",line)); END; END; EXCEPT Thread.Alerted => Wr.PutText(stdout,"Alert!\n"); | Rd.EndOfFile => Wr.PutText(stdout,"EOT\n"); END; RETURN result; END Copy; VAR t := Thread.Fork(NEW(Thread.Closure, apply := Copy)); BEGIN Thread.Alert(t); Wr.PutText(stdout,"Thread has been alerted.\n"); Wr.PutText(stdout,Fmt.F("Read %s lines\n", Fmt.Int(NARROW(Thread.Join(t),REF INTEGER)^))); END Alert. Here's some output: nr@hart (44) % a.out Thread has been alerted. one line is `one' two line is `two' three line is `three' EOT Read 3 lines Can anybody help me understand this behavior? I have a much larger, more complicated program that's getting hung on exit because there's a thread lingering around trying to read stdin and I can't successfully alert the thread. -- Norman Ramsey nr@princeton.edu