Changeset 2211

Show
Ignore:
Timestamp:
03/08/2008 08:02:04 (5 months ago)
Author:
chris
Message:

Enable logging of PID on Windows.

Enable both -k and -K options on all platforms.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/server/Daemon.cpp

    r2177 r2211  
    108108{ 
    109109        return "c:" 
    110         #ifdef WIN32 
    111                 "K" 
    112         #else // !WIN32 
    113                 "DFkP" 
     110        #ifndef WIN32 
     111                "DFP" 
    114112        #endif 
    115                 "hqt:TUvVW:"; 
     113                "hkKqt:TUvVW:"; 
    116114} 
    117115 
     
    127125        "             argument is the configuration file, or else the default \n" 
    128126        "             [" << GetConfigFileName() << "]\n" 
    129 #ifdef WIN32 
    130         "  -K         Stop writing log messages to console while daemon is running\n" 
    131 #else // !WIN32 
     127#ifndef WIN32 
    132128        "  -D         Debugging mode, do not fork, one process only, one client only\n" 
    133129        "  -F         Do not fork into background, but fork to serve multiple clients\n" 
     130#endif 
    134131        "  -k         Keep console open after fork, keep writing log messages to it\n" 
     132        "  -K         Stop writing log messages to console while daemon is running\n" 
     133#ifndef WIN32 
    135134        "  -P         Show process ID (PID) in console output\n" 
    136135#endif 
     
    166165                break; 
    167166 
    168 #ifdef WIN32 
     167#ifndef WIN32 
     168                case 'D': 
     169                { 
     170                        mSingleProcess = true; 
     171                } 
     172                break; 
     173 
     174                case 'F': 
     175                { 
     176                        mRunInForeground = true; 
     177                } 
     178                break; 
     179#endif // !WIN32 
     180 
     181                case 'k': 
     182                { 
     183                        mKeepConsoleOpenAfterFork = true; 
     184                } 
     185                break; 
     186 
    169187                case 'K': 
    170188                { 
     
    172190                } 
    173191                break; 
    174 #else // !WIN32 
    175                 case 'D': 
    176                 { 
    177                         mSingleProcess = true; 
    178                 } 
    179                 break; 
    180  
    181                 case 'F': 
    182                 { 
    183                         mRunInForeground = true; 
    184                 } 
    185                 break; 
    186  
    187                 case 'k': 
    188                 { 
    189                         mKeepConsoleOpenAfterFork = true; 
    190                 } 
    191                 break; 
    192 #endif 
    193192 
    194193                case 'h': 
     
    199198                break; 
    200199 
    201                 #ifndef WIN32 
    202200                case 'P': 
    203201                { 
     
    205203                } 
    206204                break; 
    207                 #endif 
    208205 
    209206                case 'q': 
     
    436433        std::string pidFileName; 
    437434 
    438         bool asDaemon = !mSingleProcess && !mRunInForeground; 
     435        #ifndef WIN32 
     436                bool asDaemon = !mSingleProcess && !mRunInForeground; 
     437        #endif 
    439438 
    440439        try 
     
    542541                char pid[32]; 
    543542 
    544 #ifdef WIN32 
    545                 int pidsize = sprintf(pid, "%d", (int)GetCurrentProcessId()); 
    546 #else 
    547543                int pidsize = sprintf(pid, "%d", (int)getpid()); 
    548 #endif 
    549544 
    550545                if(::write(pidFile, pid, pidsize) != pidsize)