Skip to content

Commit 3c2a749

Browse files
author
Joshua Davies
committed
Append pid to spectator filename, if form -M
1 parent e8c9798 commit 3c2a749

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

sources/spectator.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,24 @@ int CoCreateSpectator(UBYTE *inp)
123123
while ( *q && ( *q == ',' || *q == ' ' || *q == '\t' ) ) q++;
124124
if ( *q ) goto Syntax;
125125
cc = *p; *p = 0;
126+
127+
/*
128+
Append pid if AM.MultiRun. Allocate space for supplied name + '.' + 5 digits + '\0'
129+
*/
130+
char *filename2 = Malloc1(sizeof(filename) + 1 + 1 + 5, "MultiRun Spectator filename");
131+
if ( AM.MultiRun ) {
132+
sprintf(filename2, "%s.%d", filename, ((int)GetPID())%100000);
133+
}
134+
else {
135+
sprintf(filename2, "%s", filename);
136+
}
126137
/*
127138
Now we need to: create a struct for the spectator file.
128139
*/
129140
if ( HadOne == 0 )
130141
numexpr = EntVar(CEXPRESSION,inp,SPECTATOREXPRESSION,0,0,0);
131-
fh = AllocFileHandle(1,(char *)filename);
142+
fh = AllocFileHandle(1,(char *)filename2);
143+
M_free(filename2, "MultiRun Spectator filename");
132144
/*
133145
Make sure there is space in the AM.spectatorfiles array
134146
*/

0 commit comments

Comments
 (0)