blob: 105f2d3c7f3f25d15894f461efc6d19faeccf2b9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/*
* vim:ts=4:sw=4:expandtab
*
* © 2010 Michael Stapelberg
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "queue.h"
FILE *file;
/*
* Logprozess. Schreibt die empfangenen Daten in eine Datei.
*
*/
void log() {
/* Datei zum Schreiben öffnen */
if ((file = fopen("log.txt", "w")) == NULL) {
perror("fopen");
exit(EXIT_FAILURE);
}
while (1) {
/* Wir warten auf Nachrichten des CONV-Prozesses */
while (queue_get_dir() != D_CONV_TO_LOG)
usleep(1);
uint8_t data = queue_get_data();
fprintf(file, "%d\n", data);
}
}
/*
* Cleanup-Funktion (wird als Signalhandler gesetzt). Schließt die Logdatei.
*
*/
void log_cleanup() {
printf("log cleanup\n");
fclose(file);
_exit(EXIT_SUCCESS);
}
|