MCPcopy Create free account
hub / github.com/NetHack/NetHack / trace_procs_init

Function trace_procs_init

win/chain/wc_trace.c:148–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148void
149trace_procs_init(int dir)
150{
151 char tfile[20];
152 long pid;
153
154 /* processors shouldn't need this test, but just in case */
155 if (dir != WININIT)
156 return;
157
158 pid = (long) getpid();
159
160 Sprintf(tfile, "tlog.%ld", pid);
161// XXX FQN_NUMBUF is private to files.c
162 const char *fname = fqname(tfile, TROUBLEPREFIX,7);
163 printf("TRACEFILE: %s\n",fname);
164 fflush(stdout);
165 wc_tracelogf = fopen(fname, "w");
166 (void)setvbuf(wc_tracelogf, NULL, _IONBF, 0);
167 if (!wc_tracelogf) {
168 fprintf(stderr, "Can't open trace log file %s: %s\n", fname,
169 strerror(errno));
170 nh_terminate(EXIT_FAILURE);
171 }
172 setvbuf(wc_tracelogf, (char *) 0, _IONBF, 0);
173 fprintf(wc_tracelogf, "Trace log started for pid %ld\n", pid);
174
175 indent_level = 0;
176}
177
178/***
179 *** winprocs

Callers

nothing calls this directly

Calls 6

fqnameFunction · 0.85
printfFunction · 0.85
fflushFunction · 0.85
fprintfFunction · 0.85
getpidFunction · 0.70
nh_terminateFunction · 0.50

Tested by

no test coverage detected