<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://so.v2.cs.unibo.it/wiki/index.php?action=history&amp;feed=atom&amp;title=Albero_binario_2002-07-23</id>
	<title>Albero binario 2002-07-23 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://so.v2.cs.unibo.it/wiki/index.php?action=history&amp;feed=atom&amp;title=Albero_binario_2002-07-23"/>
	<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=Albero_binario_2002-07-23&amp;action=history"/>
	<updated>2026-07-01T08:16:33Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.5</generator>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=Albero_binario_2002-07-23&amp;diff=974&amp;oldid=prev</id>
		<title>Eddy: /* Soluzione di Eddy */</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=Albero_binario_2002-07-23&amp;diff=974&amp;oldid=prev"/>
		<updated>2015-04-08T06:59:54Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Soluzione di Eddy&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 06:59, 8 April 2015&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l125&quot; &gt;Line 125:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 125:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       // at least a fork returned -1&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       // at least a fork returned -1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       if (cld[0] &amp;gt; 0) kill(cld[0] ,&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;SIGCHLD&lt;/del&gt;);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       if (cld[0] &amp;gt; 0) kill(cld[0] ,&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;SIGTERM&lt;/ins&gt;);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       if (cld[1] &amp;gt; 0) kill(cld[1] ,&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;SIGCHLD&lt;/del&gt;);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       if (cld[1] &amp;gt; 0) kill(cld[1] ,&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;SIGTERM&lt;/ins&gt;);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       exit (EXIT_FAILURE);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       exit (EXIT_FAILURE);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Eddy</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=Albero_binario_2002-07-23&amp;diff=973&amp;oldid=prev</id>
		<title>Eddy: /* Soluzione di Eddy */</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=Albero_binario_2002-07-23&amp;diff=973&amp;oldid=prev"/>
		<updated>2015-04-08T06:42:38Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Soluzione di Eddy&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 06:42, 8 April 2015&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l125&quot; &gt;Line 125:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 125:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       // at least a fork returned -1&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       // at least a fork returned -1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       if (cld[0] &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;== -1&lt;/del&gt;) kill(cld[0] ,&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;SIGTERM&lt;/del&gt;);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       if (cld[0] &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;gt; 0&lt;/ins&gt;) kill(cld[0] ,&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;SIGCHLD&lt;/ins&gt;);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       if (cld[1] &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;== -1&lt;/del&gt;) kill(cld[1] ,&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;SIGTERM&lt;/del&gt;);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       if (cld[1] &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;gt; 0&lt;/ins&gt;) kill(cld[1] ,&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;SIGCHLD&lt;/ins&gt;);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       exit (EXIT_FAILURE);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;       exit (EXIT_FAILURE);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Eddy</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=Albero_binario_2002-07-23&amp;diff=972&amp;oldid=prev</id>
		<title>Eddy: Created page with &quot;Scrivere un programma C così organizzato. Si generi innanzitutto un albero binario di processi di altezza ALTEZZA. Se ALTEZZA=1, l’albero è costituito dal solo processo pr...&quot;</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=Albero_binario_2002-07-23&amp;diff=972&amp;oldid=prev"/>
		<updated>2015-04-07T23:40:19Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Scrivere un programma C così organizzato. Si generi innanzitutto un albero binario di processi di altezza ALTEZZA. Se ALTEZZA=1, l’albero è costituito dal solo processo pr...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Scrivere un programma C così organizzato. Si generi innanzitutto un albero binario di processi di altezza&lt;br /&gt;
ALTEZZA. Se ALTEZZA=1, l’albero è costituito dal solo processo principale. Se ALTEZZA &amp;gt; 1, il processo&lt;br /&gt;
padre genera due processi, che corrispondono ai figli destro e sinistro. Ognuno dei figli genera due alberi binari&lt;br /&gt;
di processi di altezza ALTEZZA-1. I processi foglia (quelli dell’ultimo livello) generano un numero casuale,&lt;br /&gt;
utilizzando le funzioni rand(), e lo comunicano al processo genitore. Il processo genitore riceve i valori dai&lt;br /&gt;
due processi figli, li somma e comunica il risultato al proprio genitore. Il procedimento termina quando il&lt;br /&gt;
processo radice riceve i valori dai propri figli e li somma. I processi foglia devono stampare l’identificatore del&lt;br /&gt;
processo e il valore generato. Tutti gli altri processi devono stampare il proprio identificatore, i valori ricevuti&lt;br /&gt;
dai figli e la somma così ottenuta. Risolvere il problema utilizzando pipe.&lt;br /&gt;
PS Per le prove, utilizzare valori bassi di altezza (3-4), per evitare di incorrere in limitazioni sul numero di&lt;br /&gt;
processi.&lt;br /&gt;
&lt;br /&gt;
==Soluzione di Eddy==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;signal.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define MAXVAL 20&lt;br /&gt;
&lt;br /&gt;
void inputH (int argc, char **argv);&lt;br /&gt;
int treeGen (int h);&lt;br /&gt;
&lt;br /&gt;
int main (int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
   int rv=0;&lt;br /&gt;
   inputH (argc, argv);&lt;br /&gt;
   treeGen (atoi(argv[1]));&lt;br /&gt;
   return rv;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void inputH (int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
   if (argc != 2)&lt;br /&gt;
   {&lt;br /&gt;
      printf (&amp;quot;Usage: %s [ALTEZZA]\n&amp;quot;, argv[0]);&lt;br /&gt;
      exit (EXIT_FAILURE);&lt;br /&gt;
   }&lt;br /&gt;
   else&lt;br /&gt;
   {&lt;br /&gt;
      int h = atoi(argv[1]);&lt;br /&gt;
      // maximum number of simultaneous processes per user ID.&lt;br /&gt;
      long cldMax = sysconf (_SC_CHILD_MAX);&lt;br /&gt;
      // NB. 2^h -1 processes in a binary tree&lt;br /&gt;
      if ( h &amp;lt; 1 || (int)pow(2, h)-1 &amp;gt; cldMax)&lt;br /&gt;
      {&lt;br /&gt;
         printf (&amp;quot;Invalid argument: ALTEZZA is too high/low\n&amp;quot;);&lt;br /&gt;
         exit (EXIT_FAILURE);&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int treeGen (int h)&lt;br /&gt;
{&lt;br /&gt;
   if (h&amp;lt;=1)&lt;br /&gt;
   {&lt;br /&gt;
      // if h==1 root is handled as a leaf&lt;br /&gt;
      // leaf: generates a random value&lt;br /&gt;
      int randV = 0;&lt;br /&gt;
      srandom ( (int) getpid());&lt;br /&gt;
      randV = random()% MAXVAL;&lt;br /&gt;
      printf (&amp;quot;**Leaf %d: number %d generated\n&amp;quot;, getpid(), randV);&lt;br /&gt;
      return randV;&lt;br /&gt;
   }&lt;br /&gt;
   else&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
      int lpipefd[2];&lt;br /&gt;
      int rpipefd[2];&lt;br /&gt;
&lt;br /&gt;
      int cValue[2]={0,0}; //child values&lt;br /&gt;
      pid_t cld [2] = {-1,-1};&lt;br /&gt;
&lt;br /&gt;
      pipe(lpipefd);&lt;br /&gt;
      pipe(rpipefd);&lt;br /&gt;
&lt;br /&gt;
      // left cld fork&lt;br /&gt;
      cld[0] = fork ();&lt;br /&gt;
&lt;br /&gt;
      if ( cld[0] == 0)&lt;br /&gt;
      {&lt;br /&gt;
&lt;br /&gt;
         close(lpipefd[0]);          /* Close unused read end */&lt;br /&gt;
         cValue[0] = treeGen (h-1);&lt;br /&gt;
         write(lpipefd[1], &amp;amp;(cValue[0]), sizeof(int));&lt;br /&gt;
         close(lpipefd[1]);&lt;br /&gt;
         exit(EXIT_SUCCESS);&lt;br /&gt;
&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      // right cld fork&lt;br /&gt;
      cld[1] = fork ();&lt;br /&gt;
&lt;br /&gt;
      if (cld[1] ==0)&lt;br /&gt;
      {&lt;br /&gt;
         close(rpipefd[0]);          /* Close unused read end */&lt;br /&gt;
         cValue[1] = treeGen (h-1);&lt;br /&gt;
         write(rpipefd[1], &amp;amp;(cValue[1]), sizeof(int));&lt;br /&gt;
         close(rpipefd[1]);&lt;br /&gt;
         exit(EXIT_SUCCESS);&lt;br /&gt;
&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      // parent&lt;br /&gt;
      if (cld[0] &amp;gt;0 &amp;amp;&amp;amp; cld[1]&amp;gt;0) {&lt;br /&gt;
         int sum =0;&lt;br /&gt;
         close(lpipefd[1]);          /* Close unused write end */&lt;br /&gt;
         close(rpipefd[1]);          /* Close unused write end */&lt;br /&gt;
&lt;br /&gt;
         wait();&lt;br /&gt;
         wait();&lt;br /&gt;
         printf (&amp;quot;##Node %d\n&amp;quot;, getpid());&lt;br /&gt;
&lt;br /&gt;
         while (read(lpipefd[0], &amp;amp;(cValue[0]), sizeof(int)) &amp;gt; 0);&lt;br /&gt;
         printf (&amp;quot;\t%d received from %d\n&amp;quot;, cValue[0], cld[0]);&lt;br /&gt;
         while (read(rpipefd[0], &amp;amp;(cValue[1]), sizeof(int)) &amp;gt; 0);&lt;br /&gt;
         printf (&amp;quot;\t%d received from %d\n&amp;quot;, cValue[1], cld[1]);&lt;br /&gt;
&lt;br /&gt;
         sum = cValue[0] + cValue[1];&lt;br /&gt;
         printf (&amp;quot;\tsum: %d\n&amp;quot;, sum);&lt;br /&gt;
         return sum;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      // at least a fork returned -1&lt;br /&gt;
      if (cld[0] == -1) kill(cld[0] ,SIGTERM);&lt;br /&gt;
      if (cld[1] == -1) kill(cld[1] ,SIGTERM);&lt;br /&gt;
&lt;br /&gt;
      exit (EXIT_FAILURE);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Eddy</name></author>
	</entry>
</feed>