mode_t mask;
char *tmpdir;
char const * const template="%s/sponge.XXXXXX";
-
+
+ trapsignals();
+ cs = cs_enter();
tmpdir = getenv("TMPDIR");
if (tmpdir == NULL)
tmpdir = "/tmp";
exit(1);
}
sprintf(tmpname, template, tmpdir);
-
- trapsignals();
- cs = cs_enter();
mask=umask(077);
tmpfd = mkstemp(tmpname);
umask(mask);
atexit(onexit_cleanup); // solaris on_exit(onexit_cleanup, 0);
cs_leave(cs);
+
if (tmpfd < 0) {
perror("mkstemp failed");
exit(1);
}
}
else {
- outfile = stdout;
if (outname) {
outfile = fopen(outname, "w");
if (!outfile) {
exit(1);
}
}
+ else {
+ outfile = stdout;
+ }
if (bufused)
write_buff_out(bufstart, bufused, outfile);
fclose(outfile);