Pristine Ack-5.5
[Ack-5.5.git] / lang / cem / ctest / ctsys / tfork.c
1 /*
2  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3  * See the copyright notice in the ACK home directory, in the file "Copyright".
4  */
5 char rcs_id[] = "$Id: tfork.c,v 2.4 1994/06/24 12:10:21 ceriel Exp $" ;
6
7 main(argc,argv) char **argv ; {
8         int child, waitchild ;
9         int status ;
10         child=fork() ;
11         if ( child== -1 ) {
12                 printf("fork returned -1\n") ;
13                 return 1 ;
14         }
15         if ( child ) {
16         /* The parent */
17                 /* printf("childno %d\n",child ) ; */
18                 do {
19                         waitchild= wait(&status ) ;
20                         /* printf("Child %d, status 0x%x\n",waitchild,status) ;*/
21                         if ( waitchild== -1 ) {
22                                 printf("No children\n") ;
23                                 return 1 ;
24                         }
25                 } while ( waitchild!=child ) ;
26                 if ( argc<=1 && status != (8<<8) ) {
27                         printf("incorrect status return\n") ;
28                         return 2 ;
29                 }
30         } else {
31                 /* The child */
32                 if ( argc>1 ) pause() ;
33                 return 8 ;
34         }
35         printf("fork/wait ok\n") ;
36         return 0 ;
37 }