77 *
88 *
99 * IDENTIFICATION
10- * $PostgreSQL: pgsql/src/port/exec.c,v 1.9 2004/05/1904:36:33 momjian Exp $
10+ * $PostgreSQL: pgsql/src/port/exec.c,v 1.10 2004/05/1917: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{
193200if (* ++ 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 );
196203return -1 ;
197204}
198205if (is_absolute_path (argv0 )|| !getcwd (buf ,MAXPGPATH ))
@@ -208,7 +215,7 @@ find_my_exec(const char *argv0, char *full_path)
208215}
209216else
210217{
211- fprintf ( stderr , "invalid binary \"%s\"" ,buf );
218+ log_error ( "invalid binary \"%s\"" ,buf );
212219return -1 ;
213220}
214221}
@@ -245,7 +252,7 @@ find_my_exec(const char *argv0, char *full_path)
245252case -1 :/* wasn't even a candidate, keep looking */
246253break ;
247254case -2 :/* found but disqualified */
248- fprintf ( stderr , "could not read binary \"%s\"" ,buf );
255+ log_error ( "could not read binary \"%s\"" ,buf );
249256free (path );
250257return -1 ;
251258}
@@ -255,7 +262,7 @@ find_my_exec(const char *argv0, char *full_path)
255262free (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 );
259266return -1 ;
260267
261268#if 0
@@ -337,17 +344,17 @@ pclose_check(FILE *stream)
337344}
338345else 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" ),
341348WEXITSTATUS (exitstatus ));
342349}
343350else 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" ),
346353WTERMSIG (exitstatus ));
347354}
348355else
349356{
350- fprintf ( stderr , _ ("child process exited with unrecognized status %d\n" ),
357+ log_error ( _ ("child process exited with unrecognized status %d\n" ),
351358exitstatus );
352359}
353360
@@ -369,7 +376,7 @@ win32_make_absolute(char *path)
369376
370377if (_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 ));
373380StrNCpy (abspath ,path ,MAXPGPATH );
374381}
375382canonicalize_path (abspath );