MCPcopy Create free account
hub / github.com/apache/cloudberry / SysLoggerMain

Function SysLoggerMain

src/backend/postmaster/syslogger.c:177–598  ·  view source on GitHub ↗

* Main entry point for syslogger process * argc/argv parameters are valid only in EXEC_BACKEND case. */

Source from the content-addressed store, hash-verified

175 * argc/argv parameters are valid only in EXEC_BACKEND case.
176 */
177NON_EXEC_STATIC void
178SysLoggerMain(int argc, char *argv[])
179{
180#ifndef WIN32
181 char logbuffer[READ_BUF_SIZE];
182 int bytes_in_logbuffer = 0;
183#endif
184 char *currentLogDir;
185 char *currentLogFilename;
186 int currentLogRotationAge;
187 pg_time_t now;
188 WaitEventSet *wes;
189
190 now = MyStartTime;
191
192#ifdef EXEC_BACKEND
193 syslogger_parseArgs(argc, argv);
194#endif /* EXEC_BACKEND */
195
196 MyBackendType = B_LOGGER;
197 if (Gp_role == GP_ROLE_DISPATCH)
198 init_ps_display("master logger process");
199 else
200 init_ps_display("logger process");
201
202 /*
203 * If we restarted, our stderr is already redirected into our own input
204 * pipe. This is of course pretty useless, not to mention that it
205 * interferes with detecting pipe EOF. Point stderr to /dev/null. This
206 * assumes that all interesting messages generated in the syslogger will
207 * come through elog.c and will be sent to write_syslogger_file.
208 */
209 {
210 int fd = open(DEVNULL, O_WRONLY, 0);
211
212 /*
213 * The closes might look redundant, but they are not: we want to be
214 * darn sure the pipe gets closed even if the open failed. We can
215 * survive running with stderr pointing nowhere, but we can't afford
216 * to have extra pipe input descriptors hanging around.
217 *
218 * As we're just trying to reset these to go to DEVNULL, there's not
219 * much point in checking for failure from the close/dup2 calls here,
220 * if they fail then presumably the file descriptors are closed and
221 * any writes will go into the bitbucket anyway.
222 */
223 close(fileno(stdout));
224 close(fileno(stderr));
225 if (fd != -1)
226 {
227 (void) dup2(fd, fileno(stdout));
228 (void) dup2(fd, fileno(stderr));
229 close(fd);
230 }
231 }
232
233 /*
234 * Syslogger's own stderr can't be the syslogPipe, so set it back to text

Callers 2

syslogger.cFile · 0.85
SubPostmasterMainFunction · 0.85

Calls 15

syslogger_parseArgsFunction · 0.85
init_ps_displayFunction · 0.85
logfile_getnameFunction · 0.85
set_next_rotation_timeFunction · 0.85
update_metainfo_datafileFunction · 0.85
CreateWaitEventSetFunction · 0.85
AddWaitEventToSetFunction · 0.85
ResetLatchFunction · 0.85
MakePGDirectoryFunction · 0.85
logfile_rotateFunction · 0.85
WaitEventSetWaitFunction · 0.85
process_pipe_inputFunction · 0.85

Tested by

no test coverage detected