Summary Files Commits Branches @commit @diff @stats
path: root / Year 3 / System programming / Practice09 / ex5-2.c
diff options
context:
space:
mode:
Commit92478827872214a442c96891a607d0781cfa6dd8 (patch)
Author
 Syndamia <kamen@syndamia.com>
2024-01-20 14:54:25 +0200
Committer
 Syndamia <kamen@syndamia.com>
2024-01-20 14:54:25 +0200
Files2bdbb6d4511eb3ad82a54b14bf15eedbd682bfdc /Year 3/System programming/Practice09/ex5-2.c
uni-projects-92478827872214a442c96891a607d0781cfa6dd8.tar
uni-projects-92478827872214a442c96891a607d0781cfa6dd8.tar.gz
uni-projects-92478827872214a442c96891a607d0781cfa6dd8.zip
Parent2f8550db96c6d6cb0cb5fe7b448f832a62dcc297 (diff)
[SP/P09] Solved exercises
1 files changed, 21 insertions, 0 deletions
-rw-r--r--Year 3/System programming/Practice09/ex5-2.c21
diff --git a/Year 3/System programming/Practice09/ex5-2.c b/Year 3/System programming/Practice09/ex5-2.c
new file mode 100644
index 0000000..1b5c83c
--- /dev/null
+++ b/Year 3/System programming/Practice09/ex5-2.c
@@ -0,0 +1,21 @@
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <mqueue.h>
+
+#include "ex5.h"
+
+int main(int argc, char* argv[]) {
+ mqd_t mq = mq_open(queueName, O_RDONLY);
+
+ char buf[64];
+ while (1) {
+ mq_receive(mq, buf, 64, NULL);
+ if (buf[0] == '\0') break;
+ write(1, buf, strlen(buf));
+ }
+
+ mq_close(mq);
+ mq_unlink(queueName);
+ return 0;
+}