Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69203 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8103 invoked from network); 18 Sep 2013 15:17:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Sep 2013 15:17:19 -0000 Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=permerror Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 78.32.209.33 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 78.32.209.33 freshmint.phcomp.co.uk Received: from [78.32.209.33] ([78.32.209.33:33551] helo=mint.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AB/71-01324-DF3C9325 for ; Wed, 18 Sep 2013 11:17:18 -0400 Received: from addw by mint.phcomp.co.uk with local (Exim 4.72) (envelope-from ) id 1VMJVC-0000K1-Cf; Wed, 18 Sep 2013 16:17:14 +0100 Date: Wed, 18 Sep 2013 16:17:14 +0100 To: Julien Pauli Cc: PHP Internals Message-ID: <20130918151714.GM20925@phcomp.co.uk> Mail-Followup-To: Julien Pauli , PHP Internals References: <20130914114540.GF3919@phcomp.co.uk> <523763A1.2090607@divbyzero.net> <20130917002719.GM3919@phcomp.co.uk> <5237F6AA.9030209@fedoraproject.org> <20130918140444.GI20925@phcomp.co.uk> <5239B513.1010204@fedoraproject.org> <20130918142052.GK20925@phcomp.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Parliament Hill Computers Ltd User-Agent: Mutt/1.5.20 (2009-12-10) Subject: Re: [PHP-DEV] PHP CLI setting cooked terminal mode From: addw@phcomp.co.uk (Alain Williams) 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