Skip to content

Commit

Permalink
Cleanup zend_/signal usage in phpdbg.c
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoebi committed Jul 12, 2016
1 parent ef6d0c8 commit d08cb90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
27 changes: 7 additions & 20 deletions sapi/phpdbg/phpdbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
+----------------------------------------------------------------------+
*/

#if !defined(ZEND_SIGNALS) || defined(_WIN32)
# include <signal.h>
#endif

#include "phpdbg.h"
#include "phpdbg_prompt.h"
#include "phpdbg_bp.h"
Expand Down Expand Up @@ -1644,6 +1640,10 @@ int main(int argc, char **argv) /* {{{ */
void (*_free)(void*);
void* (*_realloc)(void*, size_t);

zend_try {
zend_signal_activate();
} zend_end_try();

/* setup remote server if necessary */
if (cleaning <= 0 && listen > 0) {
server = phpdbg_open_socket(address, listen);
Expand All @@ -1652,15 +1652,15 @@ int main(int argc, char **argv) /* {{{ */
}

#ifndef _WIN32
sigaction(SIGIO, &sigio_struct, NULL);
zend_sigaction(SIGIO, &sigio_struct, NULL);
#endif

/* set remote flag to stop service shutting down upon quit */
remote = 1;
#ifndef _WIN32
} else {

signal(SIGHUP, phpdbg_sighup_handler);
zend_signal(SIGHUP, phpdbg_sighup_handler);
#endif
}

Expand All @@ -1682,11 +1682,6 @@ int main(int argc, char **argv) /* {{{ */
zend_mm_set_custom_handlers(mm_heap, _malloc, _free, _realloc);
}

#if defined(ZEND_SIGNALS) && !defined(_WIN32)
zend_try {
zend_signal_activate();
} zend_end_try();
#endif

phpdbg_init_list();

Expand Down Expand Up @@ -1726,31 +1721,23 @@ int main(int argc, char **argv) /* {{{ */
return 1;
}

#if defined(ZEND_SIGNALS) && !defined(_WIN32)
#ifndef _WIN32
zend_try { zend_sigaction(SIGSEGV, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); } zend_end_try();
zend_try { zend_sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal)); } zend_end_try();
#elif !defined(_WIN32)
sigaction(SIGSEGV, &signal_struct, &PHPDBG_G(old_sigsegv_signal));
sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal));
#endif

/* do not install sigint handlers for remote consoles */
/* sending SIGINT then provides a decent way of shutting down the server */
#ifndef _WIN32
if (listen < 0) {
#endif
#if defined(ZEND_SIGNALS) && !defined(_WIN32)
zend_try { zend_signal(SIGINT, phpdbg_sigint_handler); } zend_end_try();
#else
signal(SIGINT, phpdbg_sigint_handler);
#endif
#ifndef _WIN32
}

/* setup io here */
if (remote) {
PHPDBG_G(flags) |= PHPDBG_IS_REMOTE;

signal(SIGPIPE, SIG_IGN);
}
PHPDBG_G(io)[PHPDBG_STDIN].ptr = stdin;
Expand Down
8 changes: 3 additions & 5 deletions sapi/phpdbg/phpdbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@
#include "zend_globals.h"
#include "zend_ini_scanner.h"
#include "zend_stream.h"
#ifndef _WIN32
# include "zend_signal.h"
# if !defined(ZEND_SIGNALS) && defined(HAVE_SIGNAL_H)
# include <signal.h>
# endif
#include "zend_signal.h"
#if !defined(_WIN32) && !defined(ZEND_SIGNALS) && defined(HAVE_SIGNAL_H)
# include <signal.h>
#endif
#include "SAPI.h"
#include <fcntl.h>
Expand Down

0 comments on commit d08cb90

Please sign in to comment.