From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Tue, 6 Dec 2005 17:24:27 -0500 From: Russ Cox To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] alarm() and threads.. In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: Topicbox-Message-UUID: bb566fdc-ead0-11e9-9d60-3106f5b1d025 > What is the behavior of using alarm() in one of the threads > in a multi-threaded program? Which will thread will get the > note? Threads don't get notes. Processes do. The function you register with threadnotify will run in the same proc that got the note, and if that proc was in a system call, that system call will have been interrupted, regardless of which thread inside the proc was running the system call. If your code looks like: alarm(10); read(); alarm(0); then you can be sure that your thread's read is the one that will be interrupted should the alarm go off. > Also, where can I find sample code to handle terminal > abort/interrupt? Depends on what you mean by this. If you mean when the user types Delete to kill a program, that turns into a "interrupt" note. Russ