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.h"
00023
00024 bool pcsync_init(struct pcsync *p)
00025 {
00026 ec_neg1( pipe(p->fdpc) )
00027 ec_neg1( pipe(p->fdcp) )
00028 return true;
00029
00030 EC_CLEANUP_BGN
00031 return false;
00032 EC_CLEANUP_END
00033 }
00034
00035 bool pcsync_wait_for_parent(struct pcsync *p)
00036 {
00037 fd_set fdset;
00038 #if 1
00039 ec_neg1( write(p->fdcp[1], "x", 1) )
00040 FD_ZERO(&fdset);
00041 FD_SET(p->fdpc[0], &fdset);
00042 ec_neg1( select(FD_SETSIZE, &fdset, NULL, NULL, NULL) )
00043 #else
00044 #endif
00045 return true;
00046
00047 EC_CLEANUP_BGN
00048 return false;
00049 EC_CLEANUP_END
00050 }
00051
00052 bool pcsync_unblock_children(struct pcsync *p, int children,
00053 pid_t *pid_child)
00054 {
00055 int n;
00056 char c;
00057
00058 #if 1
00059 for (n = 0; n < children; n++)
00060 switch (read(p->fdcp[0], &c, 1)) {
00061 case 0:
00062 errno = 0;
00063
00064 case -1:
00065 EC_FAIL
00066 }
00067 ec_neg1( write(p->fdpc[1], "x", 1) )
00068 #endif
00069 return true;
00070
00071 EC_CLEANUP_BGN
00072 return false;
00073 EC_CLEANUP_END
00074 }
00075
00076 bool pcsync_end(struct pcsync *p)
00077 {
00078 (void)close(p->fdpc[0]);
00079 (void)close(p->fdpc[1]);
00080 (void)close(p->fdcp[0]);
00081 (void)close(p->fdcp[1]);
00082 return true;
00083 }
00084