No es fan servir funcions de rfc*.c ja.
authorviric@llimona
Sun, 26 Mar 2006 23:00:16 +0200
changeset 5 2e2e16e59af9
parent 4 f74ca12a5a41
child 6 bf2d10246ec1
No es fan servir funcions de rfc*.c ja.
syslog_in_npipe.c
--- a/syslog_in_npipe.c	Sun Mar 26 21:12:49 2006 +0200
+++ b/syslog_in_npipe.c	Sun Mar 26 23:00:16 2006 +0200
@@ -40,6 +40,7 @@
 {
 	int fd_entrada;
 	char missatge[MESSAGE_LENGTH];
+	int status;
 
 	/* Processem els parĂ metres d'entrada */
 	if (argn != 2) {
@@ -63,11 +64,22 @@
 		return 1;
 	}
 
-	while (readMessage(fd_entrada, missatge) > 0)
+	while ((status = read(fd_entrada, missatge, MESSAGE_LENGTH +1)) > 0)
 	{
+		/* Dummy */
 		printf(missatge);
 		printf("\n");
 	}
 
+	if (status < 0)
+	{
+		printf("Error reading the named pipe: %s\n",
+			strerror(errno));
+		close (fd_entrada);
+		return 1;
+	}
+
+	close (fd_entrada);
+
 	return 0;
 }