tweed / simuino

Automatically exported from code.google.com/p/simuino
0 stars 0 forks source link

Potential problem in simuino.c main() #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

I have been playing with simuino on other platform and encountered an issue in 
function main() of simuino.c.  The error file (who's filename is stored in the 
variable 'fileError'), is opened prior to it being removed & truncated several 
lines later.  This can be a problem on some systems that require exclusive 
access to the file in order to delete or truncate the file.  I think the open() 
should occur after the system() that removes the file.  The code currently 
reads:

  err = fopen(fileError,"w");
  [...]
  sprintf(syscom,"rm %s;touch %s;",fileError,fileError);
  x=system(syscom);

I think it will work more reliably if the calls were reversed:

  sprintf(syscom,"rm %s;touch %s;",fileError,fileError);
  x=system(syscom);
  [...]
  err = fopen(fileError,"w");

Original issue reported on code.google.com by smor...@gmail.com on 8 Feb 2012 at 5:53

GoogleCodeExporter commented 9 years ago

Original comment by benny.sa...@gmail.com on 9 Feb 2012 at 10:03

GoogleCodeExporter commented 9 years ago
Fixed in next version

Original comment by benny.sa...@gmail.com on 9 Feb 2012 at 5:05

GoogleCodeExporter commented 9 years ago
Fixed in version 0.1.7

Original comment by benny.sa...@gmail.com on 17 Feb 2012 at 4:31