Opened 17 years ago

Closed 17 years ago

#1971 closed defect (fixed)

MS_ERRORFILE stderr/stdout - only first error reported

Reported by: warmerdam Owned by: sdlime
Priority: high Milestone:
Component: MapServer C Library Version: 4.10
Severity: normal Keywords:
Cc:

Description

When MS_ERRORFILE is set to seterr or stdout only the first error message
actually gets reported.  This is because the following code segment ends
up fclose()ing stderr or stdout after their first use. 

  if(errfile) {
    if(strcmp(errfile, "stderr") == 0)
      errstream = stderr;
    else if(strcmp(errfile, "stdout") == 0)
      errstream = stdout;
    else
      errstream = fopen(errfile, "a");
    if(!errstream) return;
    errtime = time(NULL);
    fprintf(errstream, "%s - %s: %s %s\n", chop(ctime(&errtime)),
ms_error->routine, ms_errorCodes[ms_error->code], ms_error->message);
    fclose(errstream);
  }

The correction is to change the fclose() line to:

      if( errstream != stderr && errstream != stdout )
        fclose(errstream);

Change History (1)

comment:1 by fwarmerdam, 17 years ago

Resolution: fixed
Status: newclosed
Patch applied in 4.99 and 4.10.x branch.


Note: See TracTickets for help on using tickets.