summaryrefslogtreecommitdiff
path: root/lab10
diff options
context:
space:
mode:
Diffstat (limited to 'lab10')
-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);
}