+/**
+ * Message Queue variables
+ */
+
+/**
+ * Unique key of message queue.
+ */
+key_t qkey = 12356;
+
+/**
+ * Queue descriptor.
+ */
+int qid;
+
+/**
+ * Structure holding queue message data.
+ * Parameter mtype describes process to whom message is sent.
+ * Parameter signo is a signal to raise after getting message.
+ */
+struct queue_message {
+ long mtype;
+ int signo[1];
+};
+
+void notify_other_processes(int signo) {
+ int i = 0;
+ struct queue_message msg;
+ msg.signo[0] = signo;
+
+ for (; i < 3; i++) {
+ pid_t pid = processes->pids[i];
+ // Bleh
+ if (i != 2 && pid != 0) {
+ msg.mtype = i+1;
+ fprintf(stderr, "[%s] Sending message of type (%d) with value %d\n", "process3", msg.mtype, msg.signo[0]);
+ msgsnd(qid, &msg, sizeof(int), 0);
+ fprintf(stderr, "[%s] Sending signal %s (%d) to PID: %d\n", "process3", strsignal(SIGUSR1), SIGUSR1, pid);
+ kill(pid, SIGUSR1);
+ }
+ }
+}