void output_dump (struct output *out) { int outfd_not_empty = FD_NOT_EMPTY (out->out); int errfd_not_empty = FD_NOT_EMPTY (out->err); if (outfd_not_empty || errfd_not_empty) { int traced = 0; /* Try to acquire the semaphore. If it fails, dump the output unsynchronized; still better than silently discarding it. We want to keep this lock for as little time as possible. */ void *sem = acquire_semaphore (); /* Log the working directory for this dump. */ if (print_directory_flag && output_sync != OUTPUT_SYNC_RECURSE) traced = log_working_directory (1); if (outfd_not_empty) pump_from_tmp (out->out, stdout); if (errfd_not_empty && out->err != out->out) pump_from_tmp (out->err, stderr); if (traced) log_working_directory (0); /* Exit the critical section. */ if (sem) release_semaphore (sem); /* Truncate and reset the output, in case we use it again. */ if (out->out != OUTPUT_NONE) { int e; lseek (out->out, 0, SEEK_SET); EINTRLOOP (e, ftruncate (out->out, 0)); } if (out->err != OUTPUT_NONE && out->err != out->out) { int e; lseek (out->err, 0, SEEK_SET); EINTRLOOP (e, ftruncate (out->err, 0)); } } }
void fatal (const gmk_floc *flocp, const char *fmt, ...) { va_list args; log_working_directory (1, 0); if (flocp && flocp->filenm) fprintf (stderr, "%s:%lu: *** ", flocp->filenm, flocp->lineno); else if (makelevel == 0) fprintf (stderr, "%s: *** ", program); else fprintf (stderr, "%s[%u]: *** ", program, makelevel); va_start (args, fmt); vfprintf (stderr, fmt, args); va_end (args); fputs (_(". Stop.\n"), stderr); log_working_directory (0, 1); die (2); }
void error (const gmk_floc *flocp, const char *fmt, ...) { va_list args; log_working_directory (1, 0); if (flocp && flocp->filenm) fprintf (stderr, "%s:%lu: ", flocp->filenm, flocp->lineno); else if (makelevel == 0) fprintf (stderr, "%s: ", program); else fprintf (stderr, "%s[%u]: ", program, makelevel); va_start (args, fmt); vfprintf (stderr, fmt, args); va_end (args); putc ('\n', stderr); fflush (stderr); }
void message (int prefix, const char *fmt, ...) { va_list args; log_working_directory (1, 0); if (fmt != 0) { if (prefix) { if (makelevel == 0) printf ("%s: ", program); else printf ("%s[%u]: ", program, makelevel); } va_start (args, fmt); vfprintf (stdout, fmt, args); va_end (args); putchar ('\n'); } fflush (stdout); }