Question: I am facing a problem, which, I am sure, lot of others must have faced already.  

How to handle literals in Templates ?  

Please refer my code:

```
template<typename T, typename U>
static void Swap( T& a, U& b )
{
        T temp;
        temp = a;
        a    = (T) b;
        b    = temp;
}

int main()
{
   int i = 10, j = 20;
   //! Working
   Swap<int,int>(i,j);

   int p = 50; double q = 100.0;
   //! Working
   Swap<int,double>(p,q);

  //How to handle this case ?
   Swap<int,int>(5,10);

   return 0;
}

```

Answer: 
PHP's exec function will always wait for a response from your execution. However you can send the stdout & stderror of the process to /dev/null (on unix) and have these all the scripts executed almost instantly. This can be done by adding..

```
 '> /dev/null 2>&1 &'

```

To the end of your execution string.

But! that means they'll fork off and finish processing independently. It may be worth having them write a response back somewhere. And you could create a listener to pick this up and process it.
Quoting PHP Documentation : 

> 
> Note:
> 
> 
> If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.
> 
> 
> 

So, you can exec in background if you redirect the output in a file : 

```
exec("../path/to/script.tcl -parameter1 ".$device['param1']." -parameter2 ".$device['param2']." > outputfile.txt", $execout[$devID]);

```

But if you want to wait that ALL execs are finished before continuing, you have to make a call back from the external script. Maybe like this : 

```
exec("../path/to/script.tcl -parameter1 ".$device['param1']." -parameter2 ".$device['param2']." > ../path/to/outputfile.txt; ".PHP_BINDIR.DIRECTORY_SEPARATOR."php ../path/to/callback.php", $execout[$devID]);

```

Like this, your callback.php script will be called after every execs of script.tcl.

Maybe you can do something with these tricks.