summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo <mokha@cisco.com>2016-06-24 16:16:10 -0400
committermo <mokha@cisco.com>2016-06-24 16:16:10 -0400
commitc0f6fae97e81b84b45298614acea0a08b4cd6b04 (patch)
treed85f8fe8efc3e34249f4731f408ea6a59bba2389
parent6bfe6482696164902f831aebae4a4ef99a0f9562 (diff)
complete lab10.HEADmaster
-rw-r--r--lab10/net.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lab10/net.c b/lab10/net.c
index 7f52e20..bc811a0 100644
--- a/lab10/net.c
+++ b/lab10/net.c
@@ -91,10 +91,13 @@ void producer()
int main()
{
- /* fork a child, if I'm the child, call producer and exit */
-
- /* if I'm the parent, sleep for 1 second and call the consumer */
-
+ if (fork() == 0) {
+ /* start the producer/server first */
+ producer();
+ exit(0);
+ }
/* parent process proceeds here */
+ sleep(1);
+ consumer();
exit(0);
}