aboutsummaryrefslogtreecommitdiff
path: root/aufgabe2/main.c
diff options
context:
space:
mode:
authorThorsten Töpper <atsutane@freethoughts.de>2011-01-10 20:02:33 +0100
committerThorsten Töpper <atsutane@freethoughts.de>2011-01-10 20:02:33 +0100
commit7d28c089b45d465b18df1c5cda72abed3748118f (patch)
treeef76676071fab64337bf4e5a13a4746737a2320f /aufgabe2/main.c
parentab2f94a13428cbf1ea5f1f7acf9cf4fc33a114fb (diff)
downloadprozesskommunikation-7d28c089b45d465b18df1c5cda72abed3748118f.tar.gz
prozesskommunikation-7d28c089b45d465b18df1c5cda72abed3748118f.tar.bz2
Aufgabe 2: main.c, log.c und conv.c ausgebaut.
* main.c: Öffnen der Pipes * conv.c: Pseudozufallszahlen, schreiben in die Pipes zum log und statistic Prozess * log.c: log() implementiert
Diffstat (limited to 'aufgabe2/main.c')
-rw-r--r--aufgabe2/main.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/aufgabe2/main.c b/aufgabe2/main.c
index f876f54..1771a26 100644
--- a/aufgabe2/main.c
+++ b/aufgabe2/main.c
@@ -1,6 +1,6 @@
/*
* vim:ts=4:sw=4:expandtab
- *
+ *
*/
#include <stdio.h>
#include <unistd.h>
@@ -9,6 +9,7 @@
#include <sys/types.h>
#include <sys/wait.h>
+#include "queue.h"
#include "conv.h"
#include "log.h"
#include "monitor.h"
@@ -50,7 +51,7 @@ pid_t fork_child(funcptr work, funcptr cleanup) {
* die Prozessfunktion doch zurückkehrt. */
exit(EXIT_FAILURE);
}
-
+
if (pid == -1) {
/* error */
perror("fork()");
@@ -69,6 +70,17 @@ pid_t fork_child(funcptr work, funcptr cleanup) {
*
*/
int main() {
+
+ /*
+ * Öffnen der Pipes.
+ */
+ if ((pipe(queue[D_CONV_TO_LOG])!=0) || (pipe(queue[D_CONV_TO_STAT])!=0) ||
+ (pipe(queue[D_STAT_TO_MON])!=0)) {
+ perror("main.c pipe()");
+ exit(EXIT_FAILURE);
+ }
+
+
pconv = fork_child(conv, conv_cleanup);
plog = fork_child(log, log_cleanup);
pstatistic = fork_child(statistic, statistic_cleanup);
@@ -84,3 +96,4 @@ int main() {
return 0;
}
+