Commit 57772688 authored by vysheng's avatar vysheng

Merge pull request #56 from antma/master

remove printf from signal handlers and reduce configure.ac
parents c0e52584 7a76b66f
......@@ -6,8 +6,8 @@ CPPFLAGS=@CPPFLAGS@
DEFS=@DEFS@
COMPILE_FLAGS=${CFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -Wno-deprecated -fno-strict-aliasing -fno-omit-frame-pointer -ggdb
EXTRA_LIBS=@EXTRA_LIBS@
LOCAL_LDFLAGS=-lm -lcrypto -lz -lssl -rdynamic -ggdb ${EXTRA_LIBS}
EXTRA_LIBS=-lssl @LIBS@ @EXTRA_LIBS@
LOCAL_LDFLAGS=-rdynamic -ggdb ${EXTRA_LIBS}
LINK_FLAGS=${LDFLAGS} ${LOCAL_LDFLAGS}
HEADERS= ${srcdir}/constants.h ${srcdir}/include.h ${srcdir}/interface.h ${srcdir}/LICENSE.h ${srcdir}/loop.h ${srcdir}/mtproto-client.h ${srcdir}/mtproto-common.h ${srcdir}/net.h ${srcdir}/no-preview.h ${srcdir}/queries.h ${srcdir}/structures.h ${srcdir}/telegram.h ${srcdir}/tree.h ${srcdir}/config.h ${srcdir}/binlog.h ${srcdir}/tools.h ${srcdir}/lua-tg.h
......
......@@ -13,6 +13,9 @@
/* Define to 1 if you have the `endpwent' function. */
#define HAVE_ENDPWENT 1
/* Define to 1 if you have the <execinfo.h> header file. */
#define HAVE_EXECINFO_H 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
......@@ -31,6 +34,9 @@
/* Define to 1 if you have the `m' library (-lm). */
#define HAVE_LIBM 1
/* Define to 1 if you have the `z' library (-lz). */
#define HAVE_LIBZ 1
/* Define to 1 if you have the <luaconf.h> header file. */
#define HAVE_LUACONF_H 1
......
......@@ -12,6 +12,9 @@
/* Define to 1 if you have the `endpwent' function. */
#undef HAVE_ENDPWENT
/* Define to 1 if you have the <execinfo.h> header file. */
#undef HAVE_EXECINFO_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
......@@ -30,6 +33,9 @@
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
/* Define to 1 if you have the `z' library (-lz). */
#undef HAVE_LIBZ
/* Define to 1 if you have the <luaconf.h> header file. */
#undef HAVE_LUACONF_H
......
This diff is collapsed.
......@@ -10,25 +10,12 @@ AC_PROG_CC
# Checks for libraries.
AC_CHECK_LIB([m], [sqrt])
AC_SEARCH_LIBS([clock_gettime], [rt])
AC_SEARCH_LIBS([backtrace], [execinfo])
AC_CHECK_LIB([z], [inflate])
AC_CHECK_LIB([crypto], [AES_set_encrypt_key])
EXTRA_LIBS=""
BT=
AC_CHECK_FUNC([backtrace],
[
BT=1
],
[
]
)
if test "x$BT" = "x" ; then
AC_CHECK_LIB([execinfo], [backtrace],
[ EXTRA_LIBS="${EXTRA_LIBS} -lexecinfo" ; ],
[ CFLAGS="${CFLAGS} -DNO_BACKTRACE" ; ])
fi
AC_CHECK_LIB([readline], [rl_save_prompt],
[
AC_DEFINE([READLINE_GNU], [1], [Use gnu libreadline])
......@@ -41,14 +28,6 @@ AC_CHECK_LIB([readline], [rl_save_prompt],
]
)
AC_CHECK_LIB([rt], [clock_gettime],
[
[ EXTRA_LIBS="${EXTRA_LIBS} -lrt" ; ]
],
[
]
)
AC_MSG_CHECKING([for libconfig])
AC_ARG_ENABLE(libconfig,[--enable-libconfig/--disable-libconfig],
[
......@@ -100,7 +79,7 @@ AC_ARG_ENABLE(liblua,[--enable-liblua/--disable-liblua],
])
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h malloc.h netdb.h stdlib.h string.h unistd.h arpa/inet.h mach/mach.h netinet/in.h sys/file.h sys/socket.h termios.h])
AC_CHECK_HEADERS([execinfo.h fcntl.h malloc.h netdb.h stdlib.h string.h unistd.h arpa/inet.h mach/mach.h netinet/in.h sys/file.h sys/socket.h termios.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
......
......@@ -38,7 +38,8 @@
#include <sys/stat.h>
#include <time.h>
#include <fcntl.h>
#ifndef NO_BACKTRACE
#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#endif
#include <signal.h>
......@@ -420,7 +421,7 @@ void args_parse (int argc, char **argv) {
}
}
#ifndef NO_BACKTRACE
#ifdef HAVE_EXECINFO_H
void print_backtrace (void) {
void *buffer[255];
const int calls = backtrace (buffer, sizeof (buffer) / sizeof (void *));
......@@ -428,21 +429,27 @@ void print_backtrace (void) {
}
#else
void print_backtrace (void) {
printf ("No libexec. Backtrace disabled\n");
write (1, "No libexec. Backtrace disabled\n", 32);
}
#endif
void sig_handler (int signum) {
void sig_segv_handler (int signum __attribute__ ((unused))) {
set_terminal_attributes ();
printf ("Signal %d received\n", signum);
write (1, "SIGSEGV received\n", 18);
print_backtrace ();
exit(EXIT_FAILURE);
exit (EXIT_FAILURE);
}
void sig_abrt_handler (int signum __attribute__ ((unused))) {
set_terminal_attributes ();
write (1, "SIGABRT received\n", 18);
print_backtrace ();
exit (EXIT_FAILURE);
}
int main (int argc, char **argv) {
signal (SIGSEGV, sig_handler);
signal (SIGABRT, sig_handler);
signal (SIGSEGV, sig_segv_handler);
signal (SIGABRT, sig_abrt_handler);
log_level = 10;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment