00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "defs.h"
00022 #include "pcsync_sig.h"
00023
00024 #define NO_OPx
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 static void signal_handler_child(int signo)
00035 {
00036 }
00037
00038 bool pcsync_init(struct pcsync *p)
00039 {
00040 #ifndef NO_OP
00041 sigset_t set;
00042
00043 (void)sigemptyset(&set);
00044 (void)sigaddset(&set, SIGUSR1);
00045 ec_neg1( sigprocmask(SIG_BLOCK, &set, &p->old_set) )
00046 #endif
00047 return true;
00048
00049 EC_CLEANUP_BGN
00050 return false;
00051 EC_CLEANUP_END
00052 }
00053
00054 bool pcsync_wait_for_parent(struct pcsync *p)
00055 {
00056 #ifndef NO_OP
00057 struct sigaction act;
00058 int r;
00059 sigset_t suspendset;
00060
00061 memset(&act, 0, sizeof(act));
00062 act.sa_handler = signal_handler_child;
00063 ec_neg1( sigaction(SIGUSR1, &act, NULL) )
00064 sigfillset(&suspendset);
00065 sigdelset(&suspendset, SIGUSR1);
00066 r = sigsuspend(&suspendset);
00067 if (r == -1 && errno != EINTR)
00068 EC_FAIL
00069 ec_neg1( sigprocmask(SIG_SETMASK, &p->old_set, NULL) )
00070 #endif
00071 return true;
00072
00073 EC_CLEANUP_BGN
00074 return false;
00075 EC_CLEANUP_END
00076 }
00077
00078 bool pcsync_unblock_children(struct pcsync *p, int children,
00079 pid_t *pid_child)
00080 {
00081 #ifndef NO_OP
00082 int i;
00083
00084 ec_neg1( sigprocmask(SIG_SETMASK, &p->old_set, NULL) )
00085 for (i = 0; i < children; i++)
00086 ec_neg1( kill(pid_child[i], SIGUSR1) )
00087 #endif
00088 return true;
00089
00090 EC_CLEANUP_BGN
00091 return false;
00092 EC_CLEANUP_END
00093 }
00094
00095 bool pcsync_end(struct pcsync *p)
00096 {
00097 return true;
00098 }
00099