Skip to content

Commit c424c04

Browse files
committed
pg_ctl: Write error messages to stderr
1 parent 2dc4f01 commit c424c04

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/bin/pg_ctl/pg_ctl.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,25 +256,24 @@ get_pgpid(bool is_status_request)
256256
if (stat(pg_data, &statbuf) != 0)
257257
{
258258
if (errno == ENOENT)
259-
printf(_("%s: directory \"%s\" does not exist\n"), progname,
260-
pg_data);
259+
write_stderr(_("%s: directory \"%s\" does not exist\n"), progname,
260+
pg_data);
261261
else
262-
printf(_("%s: cannot access directory \"%s\"\n"), progname,
263-
pg_data);
262+
write_stderr(_("%s: could not access directory \"%s\": %s\n"), progname,
263+
pg_data, strerror(errno));
264264

265265
/*
266266
* The Linux Standard Base Core Specification 3.1 says this should
267267
* return '4, program or service status is unknown'
268-
* https://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-g
269-
* eneric/iniscrptact.html
268+
* https://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
270269
*/
271270
exit(is_status_request ? 4 : 1);
272271
}
273272

274273
if (stat(version_file, &statbuf) != 0 && errno == ENOENT)
275274
{
276-
printf(_("%s: directory \"%s\" is not a database cluster directory\n"),
277-
progname, pg_data);
275+
write_stderr(_("%s: directory \"%s\" is not a database cluster directory\n"),
276+
progname, pg_data);
278277
exit(is_status_request ? 4 : 1);
279278
}
280279

0 commit comments

Comments
 (0)