added set pipeSet, added function closePipes, which closes all pipes in pipeSet set
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 10 Mar 2003 20:07:28 +0000 (20:07 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 10 Mar 2003 20:07:28 +0000 (20:07 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2365 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCglue.c
src/SDCCglue.h

index 13b5a8dd624a0d1d820eca6886d89e95a2901f5c..dcca79fe1c0886dc67acd611ca822e08488ded96 100644 (file)
@@ -46,9 +46,26 @@ unsigned maxInterrupts = 6;
 int allocInfo = 1;
 symbol *mainf;
 extern char *VersionString;
+set *pipeSet = NULL;            /* set of pipes */
 set *tmpfileSet = NULL;                /* set of tmp file created by the compiler */
 set *tmpfileNameSet = NULL;    /* All are unlinked at close. */
 
+/*-----------------------------------------------------------------*/
+/* closePipes - closes all pipes created by the compiler           */
+/*-----------------------------------------------------------------*/
+DEFSETFUNC (closePipes)
+{
+  FILE *pfile = item;
+  int ret;
+
+  if (pfile) {
+    ret = pclose (pfile);
+    assert(ret != -1);
+  }
+
+  return 0;
+}
+
 /*-----------------------------------------------------------------*/
 /* closeTmpFiles - closes all tmp files created by the compiler    */
 /*                 because of BRAIN DEAD MS/DOS & CYGNUS Libraries */
@@ -56,9 +73,12 @@ set *tmpfileNameSet = NULL;  /* All are unlinked at close. */
 DEFSETFUNC (closeTmpFiles)
 {
   FILE *tfile = item;
+  int ret;
 
-  if (tfile)
-    fclose (tfile);
+  if (tfile) {
+    ret = fclose (tfile);
+    assert(ret == 0);
+  }
 
   return 0;
 }
@@ -70,12 +90,14 @@ DEFSETFUNC (closeTmpFiles)
 DEFSETFUNC (rmTmpFiles)
 {
   char *name = item;
+  int ret;
 
-  if (name)
-    {
-      unlink (name);
+  if (name) {
+      ret = unlink (name);
+      assert(ret == 0);
       Safe_free (name);
-    }
+  }
+
   return 0;
 }
 
@@ -86,6 +108,10 @@ void
 rm_tmpfiles (void)
 {
   /* close temporary files */
+  applyToSet (pipeSet, closePipes);
+  /* close temporary files */
+  deleteSet (&pipeSet);
+
   applyToSet (tmpfileSet, closeTmpFiles);
   /* remove temporary files */
   applyToSet (tmpfileNameSet, rmTmpFiles);
@@ -1837,7 +1863,7 @@ tempfile(void)
   char fnamebuf[PATH_MAX];
 
   if ((fd = tempfileandname(fnamebuf, sizeof fnamebuf)) == -1) {
-    fprintf(stderr, "Can't create temporary file name!");
+    fprintf(stderr, "Can't create temporary file!");
     exit(1);
   }
 
@@ -1846,7 +1872,7 @@ tempfile(void)
     addSetHead(&tmpfileNameSet, tmp);
 
   if ((fp = fdopen(fd, "w+b")) == NULL) {
-      perror("Can't create temporary file name!");
+      perror("Can't create temporary file!");
       exit(1);
   }
 
index e2a61cae0fd706032097d319c306325e550e8be6..0f078d2dae4e3ac6970a21204d05796f5c40f980 100644 (file)
@@ -37,6 +37,7 @@ int printIvalCharPtr (symbol *, sym_link *, value *, FILE *);
 extern symbol *interrupts[];
 extern set *publics;
 extern set *tmpfileSet;
+extern set *pipeSet;
 extern set *tmpfileNameSet;
 
 void rm_tmpfiles (void);