FAQ
Hi all,

I've been working on an extension which contains a
"debugging function". This function uses zend_printf()
to print a list of extension-specific information /
help instructions to the screen, in a similar manner
to phpinfo().

It was pointed out to me that this might be a useful
function to keep in, in a tidied-up form, when the
extension is finished.

I'm trying to ascertain the correct way to terminate
the entire calling php script, after print-out, once
this function has been called. There seem to be a
number of ways of trying to do this, but I was
wondering if there is a well-established, correct
methodology in standard use.

I had a good look at the source in the /ext directory,
but none of the extensions I looked at seem to
implement this behaviour, and I've scoured the /Zend
directory, but not managed to find anything.
[I freely concede that I could be being an incompetent
blind eejit, as I'm usually a C++/Java guy, and all
that pre-processor action has left #-marks burned into
my retina. :)]

The behaviour I'm after is something like that of
zend_error(E_ERROR, ...), but without the printout.
One method I'd considered is to change local value of
'error_reporting' / 'display_errors' and do just that,
but this might have an impact on log output, or may
not be correct.

Another idea was to call exit() from the global
function table using call_user_function_ex(). It
occurred to me, though, that this might be dangerous,
given the thread resource manager and particularly the
memory-allocation behaviour of the fourth argument -
the return value zval** (or is specifying NULL / 0
acceptable here?). I'm not sure I'd want to be
allocating heap immediately before exiting etc.

Are either of these methods valid, or are they totally
screwy / dangerous? Is there an established method for
doing this? As you can probably gather, I'm slightly
confused. Any pointers would be much appreciated.
Apologies if this is not the right list for these
matters.

Cris





___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com

Search Discussions

  • Wez Furlong at Jul 2, 2004 at 1:03 pm
    Looking at the opcode handler for exit, it looks like you can call
    zend_bailout() to terminate the request.

    Note that since exit is an opcode and not a function,
    call_user_function won't work.

    --Wez.

    On Fri, 2 Jul 2004 10:00:32 +0100 (BST), Cris H
    wrote:
    I'm trying to ascertain the correct way to terminate
    the entire calling php script, after print-out, once
    this function has been called. There seem to be a
    number of ways of trying to do this, but I was
    wondering if there is a well-established, correct
    methodology in standard use.
  • Cris H at Jul 2, 2004 at 1:47 pm

    --- Wez Furlong wrote:
    Looking at the opcode handler for exit, it looks
    like you can call
    zend_bailout() to terminate the request.

    Note that since exit is an opcode and not a
    function,
    call_user_function won't work.
    Thank you very much. A similar thought occurred to me
    (the fact that the manual refers to die/exit as
    keywords and not functions) shortly after writing the
    earlier mail.

    Since this morning's letter, I chased down the php die
    and exit keywords to the (f)lex and yacc/bison files.
    There they turned into the T_EXIT define which turned
    into a number 297 (the opcode?). This translated in
    the language parser yacc file to a call to the
    internal zend_do_exit() function. This function takes
    two znode pointers, and pulls a pointer to the next
    zend_op struct from the active_op_array. It populates
    the zend_op struct with information from one of the
    znode pointers, fills one of the members with the
    ZEND_EXIT opcode, fills other znode with some other
    information and then returns. I'm guessing that this
    population then triggers the exit as the next
    active_op_array is read. It was around then that I was
    becoming thoroughly confused figuring out how to call
    this function directly.

    zend_bailout() is a macro defined to equate to:
    _zend_bailout(__FILE__, __LINE__)
    Am I right in assuming that the __FILE__ and __LINE__
    macros would therefore be filled automatically, and
    that this is all that's necessary? If so: Many thanks
    once again. Will try it this afternoon.

    Cris







    ___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedJul 2, '04 at 9:00a
activeJul 2, '04 at 1:47p
posts3
users2
websitephp.net

2 users in discussion

Cris H: 2 posts Wez Furlong: 1 post

People

Translate

site design / logo © 2022 Grokbase