diff options
Diffstat (limited to 'waitlib')
| -rw-r--r-- | waitlib/Makefile.am | 4 | ||||
| -rw-r--r-- | waitlib/testwait.c | 27 | ||||
| -rw-r--r-- | waitlib/testwait2.c | 9 | 
3 files changed, 22 insertions, 18 deletions
diff --git a/waitlib/Makefile.am b/waitlib/Makefile.am index 33be798..5ce852d 100644 --- a/waitlib/Makefile.am +++ b/waitlib/Makefile.am @@ -1,5 +1,5 @@  # -# Copyright 1998 - 1999 Double Precision, Inc.  See COPYING for +# Copyright 1998 - 2020 Double Precision, Inc.  See COPYING for  # distribution information. @@ -10,7 +10,7 @@ EXTRA_DIST=confwait.c  libwaitlib_la_SOURCES=waitlib.c waitlib.h waitlib2.c -testwait_SOURCES=testwait.c testwait2.c +testwait_SOURCES=testwait.c  testwait_DEPENDENCIES=libwaitlib.la  testwait_LDADD=libwaitlib.la diff --git a/waitlib/testwait.c b/waitlib/testwait.c index fb0fe48..a720e49 100644 --- a/waitlib/testwait.c +++ b/waitlib/testwait.c @@ -1,5 +1,5 @@  /* -** Copyright 1998 - 2006 Double Precision, Inc. +** Copyright 1998 - 2020 Double Precision, Inc.  ** See COPYING for distribution information.  */ @@ -10,17 +10,20 @@  #include	<stdio.h>  #include	<stdlib.h>  #include	<signal.h> +#include	<pthread.h>  /* Stress test waitlib.c */  #define	NUMCHILDREN	100		/* Start 100 child processes */  #define	INITCHILDREN	10		/* Start with these many child procs */ -static unsigned started, finished; +static unsigned started; +static int reap_pipefd[2];  static void reap_child(pid_t p, int dummy)  { -	++finished; +	if (write(reap_pipefd[1], "", 1) < 0) +		; /* shut up gcc */  }  static RETSIGTYPE sighandler(int sig) @@ -58,8 +61,9 @@ int	main()  int	pipefd[2];  int	pipefd2[2];  char	c; +unsigned finished=0; -	if (pipe(pipefd) || pipe(pipefd2)) +	if (pipe(reap_pipefd) || pipe(pipefd) || pipe(pipefd2))  	{  		perror("pipe");  		exit(1); @@ -67,7 +71,7 @@ char	c;  	signal(SIGCHLD, sighandler); -	started=finished=0; +	started=0;  	while (started < INITCHILDREN)  	{  		if (start_child() == 0) @@ -87,13 +91,22 @@ char	c;  		; /* Shut gcc up */  	close(pipefd[1]);  	close(pipefd2[0]); -  	while (started < NUMCHILDREN)  		if (start_child() == 0)  			_exit(0);  	alarm(30);  	while (finished < started) -		foobar(); +	{ +		char c; +		int n=read(reap_pipefd[0], &c, 1); + +		if (n <= 0) +		{ +			fprintf(stderr, "pipe error\n"); +			exit(1); +		} +		++finished; +	}  	exit(0);  } diff --git a/waitlib/testwait2.c b/waitlib/testwait2.c deleted file mode 100644 index f64cc78..0000000 --- a/waitlib/testwait2.c +++ /dev/null @@ -1,9 +0,0 @@ -/* -** Copyright 1998 - 1999 Double Precision, Inc. -** See COPYING for distribution information. -*/ - - -void foobar() -{ -}  | 
