ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/socket++-1.10/test/tfork.C
Revision: 1.1
Committed: Mon Feb 26 15:02:39 2001 UTC (23 years, 8 months ago) by ab11
Content type: text/plain
Branch: MAIN
CVS Tags: PROJECT_COMPLETION
Log Message:
Test programs for Networking class. Unused by the host

File Contents

# User Rev Content
1 ab11 1.1 #include <iostream.h>
2     #include <Fork.h>
3    
4     static void print (char* name, pid_t child)
5     {
6     if (child) {
7     cerr << "Parent " << getppid () << "; "
8     << name << ' ' << getpid () << "; Child " << child << ";\n";
9     } else if (0) {
10     cerr << "Parent " << getppid () << "; "
11     << name << "'s child " << getpid () << ";\n";
12     }
13     }
14    
15     int main (int ac, char** av)
16     {
17     Fork::suicide_signal (SIGTERM);
18    
19     Fork a(0, 1);
20    
21     print ("a", a.process_id ());
22    
23     if (a.is_child ()) {
24     sleep (3000);
25     } else if (a.is_parent ()) {
26     Fork b (1, 1);
27     print ("b", b.process_id ());
28     {
29     Fork c (b.is_parent (), 1);
30     if (b.is_child ())
31     print ("cchild", c.process_id ());
32     else
33     print ("cparent", c.process_id ());
34     if (c.is_child ()) {
35     sleep (3000);
36     return 0;
37     }
38     }
39     if (b.is_child ()) {
40     sleep (120);
41     return 0x8;
42     }
43     }
44    
45     return 0;
46     }
47