2
Copyright (C) 2008- The University of Notre Dame
3
This software is distributed under the GNU General Public License.
4
See the file COPYING for details.
15
static struct list * complete_list = 0;
17
static void alarm_handler( int sig )
19
// do nothing except interrupt the wait
22
static int process_work( int timeout )
24
void *old_handler = 0;
31
old_handler = signal(SIGALRM,alarm_handler);
35
struct process_info p;
37
p.pid = wait4(-1,&p.status,flags,&p.rusage);
38
if(p.pid<=0) return 0;
40
struct process_info *i = malloc(sizeof(*i));
43
list_push_tail(complete_list,i);
48
struct process_info * process_wait( int timeout )
50
struct process_info *p;
52
if(!complete_list) complete_list = list_create();
54
p = list_pop_head(complete_list);
57
process_work(timeout);
59
return list_pop_head(complete_list);
62
void process_putback( struct process_info *p )
64
if(!complete_list) complete_list = list_create();
66
list_push_tail(complete_list,p);
71
if(!complete_list) complete_list = list_create();
73
if(list_size(complete_list)>0) return 1;
75
return process_work(0);