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 */
DEFSETFUNC (closeTmpFiles)
{
FILE *tfile = item;
+ int ret;
- if (tfile)
- fclose (tfile);
+ if (tfile) {
+ ret = fclose (tfile);
+ assert(ret == 0);
+ }
return 0;
}
DEFSETFUNC (rmTmpFiles)
{
char *name = item;
+ int ret;
- if (name)
- {
- unlink (name);
+ if (name) {
+ ret = unlink (name);
+ assert(ret == 0);
Safe_free (name);
- }
+ }
+
return 0;
}
rm_tmpfiles (void)
{
/* close temporary files */
+ applyToSet (pipeSet, closePipes);
+ /* close temporary files */
+ deleteSet (&pipeSet);
+
applyToSet (tmpfileSet, closeTmpFiles);
/* remove temporary files */
applyToSet (tmpfileNameSet, rmTmpFiles);
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);
}
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);
}