+/**
+ * Handler for signals.
+ */
+void sig_handler(int signo)
+{
+ fprintf(stderr, "[%s] Received %s!\n", "process2", strsignal(signo));
+ if (signo == SIGUSR1) {
+ fprintf(stderr, "[%s] > Notified!\n", "process2");
+ struct queue_message msg;
+ /* Check queues from both other processes */
+ if (msgrcv(qid, &msg, sizeof(int), 2, 0) > 0) {
+ fprintf(stderr, "[%s] > Notified with value: %s!\n", "process2", strsignal(msg.signo[0]));
+ raise(msg.signo[0]);
+ }
+ else if (msgrcv(qid, &msg, sizeof(int), 2, 0) > 0) {
+ fprintf(stderr, "[%s] > Notified with value: %s!\n", "process2", strsignal(msg.signo[0]));
+ raise(msg.signo[0]);
+ }
+ }
+ else if (signo == SIGTERM) {
+ fprintf(stderr, "[%s] > Signalling other processes..\n", "process2");
+ processes->pids[1] = 0;
+ notify_other_processes(signo);
+
+ fprintf(stderr, "[%s] > Releasing resources\n", "process2");
+ close(read_descriptor);
+ close(write_descriptor);
+ unlink(write_descriptor);
+ exit(0);
+ }
+ else if (signo == SIGTSTP) {
+ fprintf(stderr, "[%s] > Close reading pipe\n", "process2");
+ close(read_descriptor);
+ notify_other_processes(signo);
+ fprintf(stderr, "[%s] > Close writing pipe\n", "process2");
+ close(write_descriptor);
+ raise (SIGSTOP);
+ }
+ else if (signo == SIGCONT) {
+ fprintf(stderr, "[%s] > Signalling other processes..\n", "process2");
+ notify_other_processes(signo);
+
+ fprintf(stderr, "[%s] > Opening pipes\n", "process2");
+ write_descriptor = open(write_pipe, O_WRONLY);
+ read_descriptor = open(read_pipe, O_RDONLY);
+ }
+}
+
+/**
+ * Program grabs data from process1, calculates number of characters in each line
+ * and pass the value to process3.
+ */
+int main(void) {