Ejemplo n.º 1
0
void qmonSIGINT(int dummy) {
   qmon_shutdown = 1;

   if (sigint_id != 0) {
      XtNoticeSignal(sigint_id);
   }
}
Ejemplo n.º 2
0
void
DtTermSubprocReap(pid_t pid, int *stat_loc)
{
    /*
     * This procedure has special constraints, since it may be invoked
     * inside a signal handler.  That means it (and anything it calls)
     * can only use POSIX async-signal safe library routines.  A notable
     * omission from the list of reentrant routines is pthread_mutex_lock(),
     * which means we cannot call XtProcessLock() or XtAppLock().
     *
     * That makes it challenging to transfer the pid and stat_loc
     * information out of the signal handler to a routine where it is
     * safe to invoke callbacks.  Storing them in static globals will not
     * work, because overlapping signals may arrive.  The approach used
     * here is imperfect, but the best I could contrive.  We block signals
     * and then search the global data structures without using any locks. 
     * The routines that update the subprocHead list try not to leave it
     * in a transient inconsistent state, but that cannot be guaranteed.
     */

    subprocInfo *subprocTmp;
    sigset_t new_sigs;
    sigset_t old_sigs;

    /* 
     * Block additional SIGCHLD signals temporarily.  This is not
     * necessary if the handler was installed with sigaction(), but we
     * may be called from an application's signal handler, and it may
     * have been installed with signal().
     */
    (void) sigemptyset(&new_sigs);
    (void) sigaddset(&new_sigs, SIGCHLD);
    (void) sigprocmask(SIG_BLOCK, &new_sigs, &old_sigs);

    if (pid > 0) {
	/* find the subprocInfo structure for this subprocess... */
	for (subprocTmp = subprocHead->next; 
	     subprocTmp;
	     subprocTmp = subprocTmp->next) {
	    if (subprocTmp->pid == pid) {
	        if (subprocTmp->w && !subprocTmp->w->core.being_destroyed) {
		    subprocTmp->stat_loc = *stat_loc;
		    XtNoticeSignal(subprocTmp->signal_id);
		}
		break;
	    }
	}
    }

    /* Restore SIGCHLD handling to its original state. */
    (void) sigprocmask(SIG_SETMASK, &old_sigs, NULL);
}