]> granicus.if.org Git - php/commitdiff
Use sigsetjmp and siglongjmp instead of setjmp/longjmp in order to be
authorRasmus Lerdorf <rasmus@php.net>
Tue, 18 Mar 2008 18:34:11 +0000 (18:34 +0000)
committerRasmus Lerdorf <rasmus@php.net>
Tue, 18 Mar 2008 18:34:11 +0000 (18:34 +0000)
consistent in how we deal with the signal mask.  POSIX doesn't specify
what to do with the signal mask in setjmp/longjmp which has resulted in
the signal mask getting saved on *BSD and not getting saved on Linux.
Making the behaviour explicit via sigsetjmp/siglongjmp gives us
consistency and saves expensive sigprocmask() syscalls on *BSD.

Zend/zend.c
Zend/zend.h
Zend/zend_globals.h

index 1f1fa582c12de5a9d3aaff4fc56acb40bc55ba0a..a7bd8a773ddcd6dd530784b9528ec87edfc8d0b6 100644 (file)
@@ -794,7 +794,7 @@ ZEND_API void _zend_bailout(char *filename, uint lineno) /* {{{ */
        CG(unclean_shutdown) = 1;
        CG(in_compilation) = EG(in_execution) = 0;
        EG(current_execute_data) = NULL;
-       longjmp(*EG(bailout), FAILURE);
+       siglongjmp(*EG(bailout), FAILURE);
 }
 /* }}} */
 END_EXTERN_C()
index e85f40394c153a59d4c2b3484391e1758d7ede2a..2d7a21e1dc83f33d175807ef0f5538f7a9e3b95c 100644 (file)
@@ -522,11 +522,11 @@ END_EXTERN_C()
 
 #define zend_try                                                                                               \
        {                                                                                                                       \
-               jmp_buf *__orig_bailout = EG(bailout);                                  \
-               jmp_buf __bailout;                                                                              \
+               sigjmp_buf *__orig_bailout = EG(bailout);                                       \
+               sigjmp_buf __bailout;                                                                           \
                                                                                                                                \
                EG(bailout) = &__bailout;                                                               \
-               if (setjmp(__bailout)==0) {
+               if (sigsetjmp(__bailout, 0)==0) {
 #define zend_catch                                                                                             \
                } else {                                                                                                \
                        EG(bailout) = __orig_bailout;
index 0b6214ab1ec4fe490db1b33068e80f96b02909b3..3e3e34a1d6a859129676526182cc6832b3712f7f 100644 (file)
@@ -161,7 +161,7 @@ struct _zend_executor_globals {
 
        HashTable included_files;       /* files already included */
 
-       jmp_buf *bailout;
+       sigjmp_buf *bailout;
 
        int error_reporting;
        int orig_error_reporting;