On Wed, Sep 18, 2013 at 04:33:50PM +0200, Julien Pauli wrote:

> One could use ltrace -l to trace library calls.
> 
> On my laptop (Debian) :
> 
> ltrace -l /usr/lib/x86_64-linux-gnu/libedit.so.2 php -a
> 
> using_history(1, 38, 0x250000000f, 712, 0x1087900)                      = 0
> Interactive shell

Thanks - that helps. That is called in PHP_MINIT_FUNCTION(readline)
in ./ext/readline/readline.c

I have modified the initialisation function as below, using isatty() on STDIN &
STDOUT.  This will stop readline being initialised if it is not being used
interactively.

I have not even tried to compile this, I don't understand enough about how it
all hangs together to know if it will work - one concern is that if the PHP
script tries to read from STDIN it might all fail, all of the readline stuff
should probably return FALSE if it has not initialised.

PHP_MINIT_FUNCTION(readline)
{
        /* Do not start readline if not connected to a terminal on both STDIN & 
STDOUT */
        if( !isatty(0) || !isatty(1))
                return SUCCESS;

        using_history();
        return PHP_MINIT(cli_readline)(INIT_FUNC_ARGS_PASSTHRU);
}


BTW: this code has changed between php-5.5.3 & php-5.3.3. The version that I
have been using is PHP 5.3.3. The code above is from PHP 5.5.3.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to