|
|
| version 1.1.2.3, 2013/12/05 15:13:58 | version 1.1.2.4, 2013/12/05 15:38:14 |
|---|---|
| Line 198 pio_pgetpid(FILE * __restrict iop) | Line 198 pio_pgetpid(FILE * __restrict iop) |
| return p; | return p; |
| } | } |
| /* | |
| * pio_pchkpid() - Check exit status of child programs | |
| * | |
| * @pids = return tagPIOPID structures of exited programs, | |
| * if !=NULL must call array_Destroy() | |
| * return: -1 error or >-1 exited programs | |
| */ | |
| int | |
| pio_pchkpid(array_t ** __restrict pids) | |
| { | |
| register int ret = 0; | |
| struct tagPIOPID *p; | |
| array_t *pa; | |
| if (pids) { | |
| if (!(pa = array_Init(0))) | |
| return -1; | |
| else | |
| *pids = pa; | |
| } | |
| THREAD_LOCK(); | |
| SLIST_FOREACH(p, &pio_pidlist, next) | |
| if (p->fp && waitpid(p->pid, &p->stat, WNOHANG) > 0) { | |
| if (pids) | |
| array_Push(pa, p, 0); | |
| ret++; | |
| } | |
| THREAD_UNLOCK(); | |
| return ret; | |
| } |