I have child process that paused. How better to continue it? At first glance better to send SIGCONT because by documentation pause returns after EVERY signal but...
Simple test. Runned, after pausing i begin to send signals from other terminal. After this works everything but... CONT! Even SIGUSR1 works! What's going on? Why actually pause hasn't same behaivor as kill(getpid(), SIGSTOP)?Code:#include <stdio.h> #include <stdlib.h> #include <signal.h> #include <string.h> int iceu_signals_init_signal_handler(const sigset_t ........et, __sighandler_t/*__sighandler_t*/ sgnhnd) { static struct sigaction sa_act; int i; // memset(&sa_act, 0, sizeof(sa_act)); sa_act.sa_handler=sgnhnd; // blocking all signals while handler occurs: if (sigfillset(&(sa_act.sa_mask))) { fprintf(stderr, "Cannot fill set of all signals\n"); return 1; } for (i=1; i<=_SIGSET_NWORDS; i++) { switch (sigismember(sset, i)) { case 1: if(sigaction(i, &sa_act, NULL)) { fprintf(stderr, "Cannot set signal %i(%s)\n", i, sys_siglist[i]); return 10*i; } break; case 0: continue; case -1: { fprintf(stderr, "Cannot check signal membership: %i(%s)\n", i, sys_siglist[i]); return 5; } } } return 0; } int iceu_signals_set_signals(sigset_t ........et, const int *set, int cnt) { int i; // if (sigemptyset(sset)) { fprintf(stderr, "Cannot do empty set of signals\n"); return 1; } for (i=0;i<cnt;i++) { if (sigaddset(sset, set[i])) { fprintf(stderr, "Cannot add to set signal %i(%s)\n", set[i], sys_siglist[set[i]]); return set[i]*100+1; } } return 0; } static void ProcessSigHandler(int sg) { if (sg==SIGSTOP) fprintf(stderr, "Process stopped\n"); } int main() { //1) register signals static sigset_t sset; int s=SIGSTOP; // if (iceu_signals_set_signals(&sset, &s, 1)) return 1; iceu_signals_init_signal_handler(&sset, &ProcessSigHandler); fprintf(stderr, "Process started\n"); pause(); //kill(getpid(), SIGSTOP); kill(getpid(), SIGCONT); fprintf(stderr, "Process is about to terminate\n"); return 0; }
---------
istead of ........ should be "*\ss" in code. Admins, do smth with editor, please



LinkBack URL
About LinkBacks




Nothing understood but sounds good