Skip to content

Commit 1e5cfa6

Browse files
committed
Try to create the sort file at startup.
If a bad path for FORMTMPSORT is specified, FORM doesn't notice until it tries to create a sort file and can't. In principle one can create a script which takes a long time to reach this point. Try to create the file immediately at startup, and Terminate if this fails.
1 parent 328e810 commit 1e5cfa6

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

check/features.frm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,3 +1135,13 @@ Print +s;
11351135
assert succeeded?
11361136
assert result("F") =~ expr("0");
11371137
*--#] Sortrealloc_2 :
1138+
*--#[ TempSortDir :
1139+
#: TempSortDir bad/path
1140+
Local test = 1;
1141+
.end
1142+
if mpi?
1143+
assert runtime_error?("Could not create sort file: bad/path/0formxxx.sor")
1144+
else
1145+
assert runtime_error?("Could not create sort file: bad/path/xformxxx.sor")
1146+
end
1147+
*--#] TempSortDir :

sources/startup.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,17 @@ classic:;
801801
while ( *t ) { *s++ = *t++; i++; }
802802
s[-2] = 'o'; *s = 0;
803803
}
804+
/*
805+
Try to create the sort file already, so we can Terminate earlier if this fails.
806+
*/
807+
if ( ( AM.S0->file.handle = CreateFile((char *)AM.S0->file.name) ) < 0 ) {
808+
MesPrint("Could not create sort file: %s", AM.S0->file.name);
809+
Terminate(-1);
810+
};
811+
/* Close and clean up the test file */
812+
CloseFile(AM.S0->file.handle);
813+
AM.S0->file.handle = -1;
814+
remove(AM.S0->file.name);
804815
/*
805816
With the stage4 and scratch file names we have to be a bit more careful.
806817
They are to be allocated after the threads are initialized when there

0 commit comments

Comments
 (0)