77 *
88 *
99 * IDENTIFICATION
10- * $PostgreSQL: pgsql/src/port/exec.c,v 1.9 2004/05/19 04:36:33 momjian Exp $
10+ * $PostgreSQL: pgsql/src/port/exec.c,v 1.10 2004/05/19 17:15:21 momjian Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
4848#define S_IXOTH ((S_IXUSR)>>6)
4949#endif
5050
51+ #ifndef FRONTEND
52+ /* We use only 3-parameter elog calls in this file, for simplicity */
53+ #define log_error (str , param ) elog(LOG, (str), (param))
54+ #else
55+ #define log_error (str , param ) fprintf(stderr, (str), (param))
56+ #endif
57+
5158static void win32_make_absolute (char * path );
5259
5360/*
@@ -192,7 +199,7 @@ find_my_exec(const char *argv0, char *full_path)
192199 {
193200 if (* ++ p == '\0' )
194201 {
195- fprintf ( stderr , "argv[0] ends with a path separator \"%s\"" , argv0 );
202+ log_error ( "argv[0] ends with a path separator \"%s\"" , argv0 );
196203 return -1 ;
197204 }
198205 if (is_absolute_path (argv0 ) || !getcwd (buf , MAXPGPATH ))
@@ -208,7 +215,7 @@ find_my_exec(const char *argv0, char *full_path)
208215 }
209216 else
210217 {
211- fprintf ( stderr , "invalid binary \"%s\"" , buf );
218+ log_error ( "invalid binary \"%s\"" , buf );
212219 return -1 ;
213220 }
214221 }
@@ -245,7 +252,7 @@ find_my_exec(const char *argv0, char *full_path)
245252 case -1 : /* wasn't even a candidate, keep looking */
246253 break ;
247254 case -2 : /* found but disqualified */
248- fprintf ( stderr , "could not read binary \"%s\"" , buf );
255+ log_error ( "could not read binary \"%s\"" , buf );
249256 free (path );
250257 return -1 ;
251258 }
@@ -255,7 +262,7 @@ find_my_exec(const char *argv0, char *full_path)
255262 free (path );
256263 }
257264
258- fprintf ( stderr , "could not find a \"%s\" to execute" , argv0 );
265+ log_error ( "could not find a \"%s\" to execute" , argv0 );
259266 return -1 ;
260267
261268#if 0
@@ -337,17 +344,17 @@ pclose_check(FILE *stream)
337344 }
338345 else if (WIFEXITED (exitstatus ))
339346 {
340- fprintf ( stderr , _ ("child process exited with exit code %d\n" ),
347+ log_error ( _ ("child process exited with exit code %d\n" ),
341348 WEXITSTATUS (exitstatus ));
342349 }
343350 else if (WIFSIGNALED (exitstatus ))
344351 {
345- fprintf ( stderr , _ ("child process was terminated by signal %d\n" ),
352+ log_error ( _ ("child process was terminated by signal %d\n" ),
346353 WTERMSIG (exitstatus ));
347354 }
348355 else
349356 {
350- fprintf ( stderr , _ ("child process exited with unrecognized status %d\n" ),
357+ log_error ( _ ("child process exited with unrecognized status %d\n" ),
351358 exitstatus );
352359 }
353360
@@ -369,7 +376,7 @@ win32_make_absolute(char *path)
369376
370377 if (_fullpath (abspath , path , MAXPGPATH ) == NULL )
371378 {
372- fprintf ( stderr , "Win32 path expansion failed: %s" , strerror (errno ));
379+ log_error ( "Win32 path expansion failed: %s" , strerror (errno ));
373380 StrNCpy (abspath , path , MAXPGPATH );
374381 }
375382 canonicalize_path (abspath );
0 commit comments