Ignore:
Timestamp:
Jan 8, 2014 8:32:39 PM (10 years ago)
Author:
ldelgass
Message:

Prep servers for accepting arguments to change file descriptors for IO. This
will allow us to send stdout to the trace log along with stderr so chatty
libraries won't send garbage to the socket. Fall back to stdin/stdout to allow
debugging without nanoscale.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/vtkvis/RenderServer.cpp

    r3994 r4105  
    4545int VtkVis::g_fdIn = STDIN_FILENO; ///< Input file descriptor
    4646int VtkVis::g_fdOut = STDOUT_FILENO; ///< Output file descriptor
    47 FILE *VtkVis::g_fOut = stdout; ///< Output file handle
     47FILE *VtkVis::g_fOut = NULL; ///< Output file handle
    4848FILE *VtkVis::g_fLog = NULL; ///< Trace logging file handle
    4949Renderer *VtkVis::g_renderer = NULL; ///< Main render worker
     
    407407initService()
    408408{
    409     TRACE("Enter");
     409    g_fOut = fdopen(g_fdOut, "w");
     410    // If running without socket, use stdout for debugging
     411    if (g_fOut == NULL && g_fdOut != STDOUT_FILENO) {
     412        g_fdOut = STDOUT_FILENO;
     413        g_fOut = fdopen(g_fdOut, "w");
     414    }
    410415
    411416    const char *user = getenv("USER");
     
    428433    // open log and map stderr to log file
    429434    g_fLog = fopen(logName, "w");
    430     close(STDERR_FILENO);
    431435    dup2(fileno(g_fLog), STDERR_FILENO);
    432     // flush junk
    433     fflush(stderr);
     436    // If we are writing to socket, map stdout to log
     437    if (g_fdOut != STDOUT_FILENO) {
     438        dup2(fileno(g_fLog), STDOUT_FILENO);
     439    }
     440
     441    fflush(stdout);
    434442
    435443    // clean up malloc'd memory
     
    437445        free(logName);
    438446    }
    439 
    440     TRACE("Leave");
    441447}
    442448
     
    444450exitService()
    445451{
    446     TRACE("Enter");
    447 
    448452    serverStats(0);
    449453
Note: See TracChangeset for help on using the changeset viewer.