/*----------------------------------------------------------------------------- * SignalTrap -- * * Trap handler for UNIX signals. Sets tells all registered interpreters * that a trap has occured and saves the trap info. The first interpreter to * call it's async signal handler will process all pending signals. *----------------------------------------------------------------------------- */ static RETSIGTYPE SignalTrap (int signalNum) { if (asyncHandler == NULL) return; /* * Record the count of the number of this type of signal that has occured * and tell all the interpreters to call the async handler when safe. */ signalsReceived [signalNum]++; Tcl_AsyncMark (asyncHandler); #ifdef NO_SIGACTION /* * For old-style Unix signals, the signal must be explictly re-enabled. * Not done for SIGCHLD, as we would continue to the signal until the * wait is done. This is fixed by Posix signals and is not necessary under * BSD, but it done this way for consistency. */ #ifdef SIGCHLD if (signalNum != SIGCHLD) { if (SetSignalState (signalNum, SignalTrap, FALSE) == TCL_ERROR) panic ("SignalTrap bug"); } #else if (SetSignalState (signalNum, SignalTrap, FALSE) == TCL_ERROR) panic ("SignalTrap bug"); #endif /* SIGCHLD */ #endif /* NO_SIGACTION */ }
static void WakeManagerThread (void) { #ifdef TCL_THREADS condReady = 1; Tcl_ConditionNotify(&spointsCV); #else Tcl_AsyncMark(activator); #endif }
static void signalHandler(int signum) { ElTclSignalContext *ctx; #ifdef SIGWINCH for(ctx = sigWinchContext; ctx != NULL; ctx=ctx->next) { el_resize(ctx->iinfo->el); elTclGetWindowSize(1, NULL, &ctx->iinfo->windowSize); } #endif for(ctx = signalContext[signum]; ctx != NULL; ctx=ctx->next) if (ctx->script != ELTCL_SIGDFL && ctx->script != ELTCL_SIGIGN) Tcl_AsyncMark(ctx->asyncH); #ifdef __svr4__ /* solaris 2 */ signal(signum, signalHandler); #endif }
void signal_handler(int sig) { lastsig=sig; Tcl_AsyncMark(asynchandler); }
/*----------------------------------------------------------------------------- * ProcessSignals -- * * Called by the async handler to process pending signals in a safe state * interpreter state. This is often called just after a command completes. * The results of the command are passed to this procedure and may be altered * by it. If trap code is specified for the signal that was received, then * the trap will be executed, otherwise an error result will be returned * indicating that the signal occured. If an error is returned, clear the * errorInfo variable. This makes sure it exists and that it is empty, * otherwise bogus or non-existant information will be returned if this * routine was called somewhere besides Tcl_Eval. If a signal was received * multiple times and a trap is set on it, then that trap will be executed for * each time the signal was received. * * Parameters: * o clientData - Not used. * o interp (I/O) - interp result should contain the result for * the command that just executed. This will either be restored or * replaced with a new result. If this is NULL, then no interpreter * is directly available (i.e. event loop). In this case, the first * interpreter in internal interpreter table is used. If an error results * from signal processing, it is handled via Tcl_BackgroundError. * o cmdResultCode - The integer result returned by the command that * Tcl_Eval just completed. Should be TCL_OK if not called from * Tcl_Eval. * Returns: * Either the original result code, an error result if one of the * trap commands returned an error, or an error indicating the * a signal occured. *----------------------------------------------------------------------------- */ static int ProcessSignals (ClientData clientData, Tcl_Interp *interp, int cmdResultCode) { Tcl_Interp *sigInterp; Tcl_Obj *errStateObjPtr; int signalNum, result; /* * Get the interpreter if it wasn't supplied, if none is available, * bail out. */ if (interp == NULL) { if (numInterps == 0) return cmdResultCode; sigInterp = interpTable [0]; } else { sigInterp = interp; } errStateObjPtr = TclX_SaveResultErrorInfo (sigInterp); /* * Process all signals. Don't process any more if one returns an error. */ result = TCL_OK; for (signalNum = 1; signalNum < MAXSIG; signalNum++) { if (signalsReceived [signalNum] == 0) continue; result = ProcessASignal (sigInterp, (interp == NULL), signalNum); if (result == TCL_ERROR) break; } /* * Restore result and error state if we didn't get an error in signal * handling. */ if (result != TCL_ERROR) { TclX_RestoreResultErrorInfo (sigInterp, errStateObjPtr) ; } else { Tcl_DecrRefCount (errStateObjPtr); cmdResultCode = TCL_ERROR; } /* * Reset the signal received flag in case more signals are pending. */ for (signalNum = 1; signalNum < MAXSIG; signalNum++) { if (signalsReceived [signalNum] != 0) break; } if (signalNum < MAXSIG) { if (asyncHandler) Tcl_AsyncMark (asyncHandler); } /* * If a signal handler returned an error and an interpreter was not * supplied, call the background error handler. */ if ((result == TCL_ERROR) && (interp == NULL)) { Tcl_BackgroundError (sigInterp); } return cmdResultCode; }
void VMDTclSigHandler(int) { Tcl_AsyncMark(tclhandler); }