C homework with pipes and forks : <p><strong>Hello everyone,</strong> </p>

<p>I'm quite lost in my school homework since they haven't told us much about it and I haven't done anything like that before.</p>

<p><strong>The task is:</strong></p>

<p><em>In the C language create a program that creates two processes (fork function) and connects them via pipe (the pipe function).
The first descendant redirects its' stdout into the pipe and writes (space separated) pairs of random numbers into it (function rand).
Delay the output of the numbers (i.e. by 1 second).</em></p>

<p><em>The first descendant has 
to treat the SIGUSR1 signal (sigaction function) and in case of receiving such signal it prints a string “TERMINATED” to it's stderr and terminates.</em></p>

<p><em>The second descendant redirects the pipe output to it's stdin, redirects it's stdout into a file called out.txt in 
the current directory and executes a binary file (execl function) for finding the greatest common divisor (the output of our previous tasks where we had to write a makefile that runs a small C program that detects if a number is prime).</em></p>

<p><em>The parent process waits 5 seconds and then sends SIGUSR1 to the first process (number generator). This should perform a correct termination of both processes. It waits for the sub-processes to terminate (wait function) and terminates itself.</em></p>

<p><em>In fact you are implementing something like this: while : ; do echo $RANDOM $RANDOM ; sleep 1; done | ./c1_task > out.txt</em></p>

<p>I'm absolutely lost in this and I have nothing so far unfortunatelly.
I don't know where to start.</p>

<p>Could somebody advise me something, please?</p>

<p>Thanks in advance!</p>
