1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
-
+
|
/*
* tclUnixNotify.c --
*
* This file contains the implementation of the select-based
* Unix-specific notifier, which is the lowest-level part
* of the Tcl event loop. This file works together with
* generic/tclNotify.c.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclUnixNotfy.c,v 1.25 2005/05/31 11:37:46 vasiljevic Exp $
* RCS: @(#) $Id: tclUnixNotfy.c,v 1.26 2005/06/01 09:38:05 dkf Exp $
*/
#ifndef HAVE_COREFOUNDATION /* Darwin/Mac OS X CoreFoundation notifier
* is in tclMacOSXNotify.c */
#include "tclInt.h"
#include <signal.h>
|
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
-
+
-
+
|
/*
* If this is the last thread to use the notifier, close the notifier
* pipe and wait for the background thread to terminate.
*/
if (notifierCount == 0) {
int result;
int result, ignored;
if (triggerPipe < 0) {
Tcl_Panic("Tcl_FinalizeNotifier: notifier pipe not initialized");
}
/*
* Send "q" message to the notifier thread so that it will
* terminate. The notifier will return from its call to select()
* and notice that a "q" message has arrived, it will then close
* its side of the pipe and terminate its thread. Note the we can
* not just close the pipe and check for EOF in the notifier
* thread because if a background child process was created with
* exec, select() would not register the EOF on the pipe until the
* child processes had terminated. [Bug: 4139]
*/
write(triggerPipe, "q", 1);
close(triggerPipe);
Tcl_ConditionWait(¬ifierCV, ¬ifierMutex, NULL);
result = Tcl_JoinThread(notifierThread);
result = Tcl_JoinThread(notifierThread, &ignored);
if (result) {
Tcl_Panic("Tcl_FinalizeNotifier: unable to join notifier thread");
}
}
/*
* Clean up any synchronization objects in the thread local storage.
|