Note: The latest code has fixed this bughttps: // code.google.com/p/google-glog/issues/detail? Id = 142
Https://code.google.com/p/google-glog/source/browse/trunk/src/utilities.cc
The cause is very simple, utilities. shutdowngoogleloggingutilities in the CC file does not reset the Global static variable g_program_invocation_short_name to null. The following is the source code. The solution is to add g_program_invocation_short_name = NULL, because it is a static global variable, you cannot perform this operation in your own program unless you change it to a non-static global variable.
Source code file logging. CC1803 voidInitgooglelogging(Const char * argv0) {1804 glog_internal_namespace _: initgoogleloggingutilities (argv0); 1805} 1806 voidShutdowngooglelogging() {1808 glog_internal_namespace _: shutdowngoogleloggingutilities (); 1809 logdestination: deletelogdestinations (); 1810 Delete logging_directories_list; 1811 logging_directories_list = NULL; 1812}
Source code file src/utilities. CC57 static const char *G_program_invocation_short_name= NULL;
167 boolIsgooglelogginginitialized() {168 return g_program_invocation_short_name! = NULL, 169}
316 voidInitgoogleloggingutilities(Const char * argv0) {317 check (! Isgooglelogginginitialized () 318 <"You called initgooglelogging () twice! "; 319 const char * slash = strrchr (argv0, '/'); 320 # ifdef OS _windows321 if (! Slash) slash = strrchr (argv0, '\'); 322 # endif323 g_program_invocation_short_name = slash? Slash + 1: argv0; 324 g_main_thread_id = pthread_self (); 325 326 # ifdef have_stacktrace327 installfailurefunction (& dumpstacktraceandexit); 328 # endif329} 330 331 voidShutdowngoogleloggingutilities() {332 check (isgooglelogginginitialized () 333 <"You called shutdowngooglelogging () without calling initgooglelogging () first! "; 334 # ifdef have_syslog_h335 closelog (); 336 # endifG_program_invocation_short_name = NULL;337}