mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-01 12:19:28 +00:00
Improve temporary file handling
Obtained from: OpenBSD
This commit is contained in:
parent
d07a0d1d4c
commit
dd0208b307
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=178973
@ -100,6 +100,7 @@ int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
int fdesc;
|
||||
|
||||
while ((c = getopt(argc, argv, "-cv")) != -1)
|
||||
switch (c) {
|
||||
@ -122,8 +123,16 @@ main(int argc, char *argv[])
|
||||
signal(SIGINT, onintr);
|
||||
if (cflg || (argc == 0 && !readstd))
|
||||
inithash();
|
||||
else
|
||||
strings = mktemp(strdup(_PATH_TMP));
|
||||
else {
|
||||
strings = strdup(_PATH_TMP);
|
||||
if (strings == NULL)
|
||||
err(1, "strdup() failed");
|
||||
fdesc = mkstemp(strings);
|
||||
if (fdesc == -1)
|
||||
err(1, "Unable to create temporary file");
|
||||
close(fdesc);
|
||||
}
|
||||
|
||||
while (readstd || argc > 0) {
|
||||
if (freopen("x.c", "w", stdout) == NULL)
|
||||
err(1, "x.c");
|
||||
|
Loading…
Reference in New Issue
Block a user