Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 82480fc

Browse files
committed
Use sys_siglist[] to print out signal names for signal exits, rather
than just numbers.
1 parent 3ec7ae1 commit 82480fc

File tree

5 files changed

+100
-12
lines changed

5 files changed

+100
-12
lines changed

configure

+62
Original file line numberDiff line numberDiff line change
@@ -15600,6 +15600,68 @@ fi
1560015600
rm -f conftest.err conftest.$ac_objext \
1560115601
conftest$ac_exeext conftest.$ac_ext
1560215602

15603+
echo "$as_me:$LINENO: checking for sys_siglist" >&5
15604+
echo $ECHO_N "checking for sys_siglist... $ECHO_C" >&6
15605+
if test "${pgac_cv_var_sys_siglist+set}" = set; then
15606+
echo $ECHO_N "(cached) $ECHO_C" >&6
15607+
else
15608+
cat >conftest.$ac_ext <<_ACEOF
15609+
/* confdefs.h. */
15610+
_ACEOF
15611+
cat confdefs.h >>conftest.$ac_ext
15612+
cat >>conftest.$ac_ext <<_ACEOF
15613+
/* end confdefs.h. */
15614+
#include <signal.h>
15615+
int
15616+
main ()
15617+
{
15618+
extern char *sys_siglist[]; (void)sys_siglist[0];
15619+
;
15620+
return 0;
15621+
}
15622+
_ACEOF
15623+
rm -f conftest.$ac_objext conftest$ac_exeext
15624+
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
15625+
(eval $ac_link) 2>conftest.er1
15626+
ac_status=$?
15627+
grep -v '^ *+' conftest.er1 >conftest.err
15628+
rm -f conftest.er1
15629+
cat conftest.err >&5
15630+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
15631+
(exit $ac_status); } &&
15632+
{ ac_try='test -z "$ac_c_werror_flag"
15633+
|| test ! -s conftest.err'
15634+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
15635+
(eval $ac_try) 2>&5
15636+
ac_status=$?
15637+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
15638+
(exit $ac_status); }; } &&
15639+
{ ac_try='test -s conftest$ac_exeext'
15640+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
15641+
(eval $ac_try) 2>&5
15642+
ac_status=$?
15643+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
15644+
(exit $ac_status); }; }; then
15645+
pgac_cv_var_sys_siglist=yes
15646+
else
15647+
echo "$as_me: failed program was:" >&5
15648+
sed 's/^/| /' conftest.$ac_ext >&5
15649+
15650+
pgac_cv_var_sys_siglist=no
15651+
fi
15652+
rm -f conftest.err conftest.$ac_objext \
15653+
conftest$ac_exeext conftest.$ac_ext
15654+
fi
15655+
echo "$as_me:$LINENO: result: $pgac_cv_var_sys_siglist" >&5
15656+
echo "${ECHO_T}$pgac_cv_var_sys_siglist" >&6
15657+
if test x"$pgac_cv_var_sys_siglist" = x"yes"; then
15658+
15659+
cat >>confdefs.h <<\_ACEOF
15660+
#define HAVE_SYS_SIGLIST 1
15661+
_ACEOF
15662+
15663+
fi
15664+
1560315665
echo "$as_me:$LINENO: checking for syslog" >&5
1560415666
echo $ECHO_N "checking for syslog... $ECHO_C" >&6
1560515667
if test "${ac_cv_func_syslog+set}" = set; then

configure.in

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.497 2007/01/18 14:07:31 petere Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.498 2007/01/28 01:12:05 momjian Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -1059,6 +1059,15 @@ AC_TRY_LINK([#include <setjmp.h>],
10591059
AC_MSG_RESULT(yes)],
10601060
[AC_MSG_RESULT(no)])
10611061

1062+
AC_CACHE_CHECK([for sys_siglist], pgac_cv_var_sys_siglist,
1063+
[AC_TRY_LINK([#include <signal.h>],
1064+
[extern char *sys_siglist[]; (void)sys_siglist[0];],
1065+
[pgac_cv_var_sys_siglist=yes],
1066+
[pgac_cv_var_sys_siglist=no])])
1067+
if test x"$pgac_cv_var_sys_siglist" = x"yes"; then
1068+
AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define to 1 if you have the global variable 'char *sys_siglist[]'.])
1069+
fi
1070+
10621071
AC_CHECK_FUNC(syslog,
10631072
[AC_CHECK_HEADER(syslog.h,
10641073
[AC_DEFINE(HAVE_SYSLOG, 1, [Define to 1 if you have the syslog interface.])])])

src/backend/postmaster/postmaster.c

+17-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.512 2007/01/23 03:28:49 momjian Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.513 2007/01/28 01:12:05 momjian Exp $
4141
*
4242
* NOTES
4343
*
@@ -2421,23 +2421,33 @@ LogChildExit(int lev, const char *procname, int pid, int exitstatus)
24212421
(errmsg("%s (PID %d) exited with exit code %d",
24222422
procname, pid, WEXITSTATUS(exitstatus))));
24232423
else if (WIFSIGNALED(exitstatus))
2424-
#ifndef WIN32
2424+
#if defined(WIN32)
24252425
ereport(lev,
24262426

24272427
/*------
24282428
translator: %s is a noun phrase describing a child process, such as
24292429
"server process" */
2430-
(errmsg("%s (PID %d) was terminated by signal %d",
2431-
procname, pid, WTERMSIG(exitstatus))));
2430+
(errmsg("%s (PID %d) was terminated by exception %X",
2431+
procname, pid, WTERMSIG(exitstatus)),
2432+
errhint("See C include file \"ntstatus.h\" for a description of the hex value.")));
2433+
#elif defined(HAVE_SYS_SIGLIST)
2434+
ereport(lev,
2435+
2436+
/*------
2437+
translator: %s is a noun phrase describing a child process, such as
2438+
"server process" */
2439+
(errmsg("%s (PID %d) was terminated by signal: %s (%d)",
2440+
procname, pid, WTERMSIG(exitstatus) < NSIG ?
2441+
sys_siglist[WTERMSIG(exitstatus)] : "unknown signal",
2442+
WTERMSIG(exitstatus))));
24322443
#else
24332444
ereport(lev,
24342445

24352446
/*------
24362447
translator: %s is a noun phrase describing a child process, such as
24372448
"server process" */
2438-
(errmsg("%s (PID %d) was terminated by exception %X",
2439-
procname, pid, WTERMSIG(exitstatus)),
2440-
errhint("See /include/ntstatus.h for a description of the hex value.")));
2449+
(errmsg("%s (PID %d) was terminated by signal %d",
2450+
procname, pid, WTERMSIG(exitstatus))));
24412451
#endif
24422452
else
24432453
ereport(lev,

src/include/pg_config.h.in

+3
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,9 @@
478478
/* Define to 1 if you have the <sys/shm.h> header file. */
479479
#undef HAVE_SYS_SHM_H
480480

481+
/* Define to 1 if you have the global variable 'char *sys_siglist[]'. */
482+
#undef HAVE_SYS_SIGLIST
483+
481484
/* Define to 1 if you have the <sys/socket.h> header file. */
482485
#undef HAVE_SYS_SOCKET_H
483486

src/port/exec.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/port/exec.c,v 1.48 2007/01/23 03:31:33 momjian Exp $
12+
* $PostgreSQL: pgsql/src/port/exec.c,v 1.49 2007/01/28 01:12:05 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -582,11 +582,15 @@ pclose_check(FILE *stream)
582582
log_error(_("child process exited with exit code %d"),
583583
WEXITSTATUS(exitstatus));
584584
else if (WIFSIGNALED(exitstatus))
585-
#ifndef WIN32
586-
log_error(_("child process was terminated by signal %d"),
585+
#if defined(WIN32)
586+
log_error(_("child process was terminated by exception %X\nSee C include file \"ntstatus.h\" for a description of the hex value."),
587587
WTERMSIG(exitstatus));
588+
#elif defined(HAVE_SYS_SIGLIST)
589+
log_error(_("child process was terminated by signal: %s"),
590+
WTERMSIG(exitstatus) < NSIG ?
591+
sys_siglist[WTERMSIG(exitstatus)] : "unknown signal");
588592
#else
589-
log_error(_("child process was terminated by exception %X\nSee /include/ntstatus.h for a description of the hex value."),
593+
log_error(_("child process was terminated by signal %d"),
590594
WTERMSIG(exitstatus));
591595
#endif
592596
else

0 commit comments

Comments
 (0)