From: Tim Starling Date: Wed, 18 Jul 2018 05:47:23 +0000 (+1000) Subject: In mysql.php ignore SIGINT X-Git-Tag: 1.34.0-rc.0~4705^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=9dcd605d13188b43edbed8760bdf7984ac1c1a00 In mysql.php ignore SIGINT Every foreground process with the terminal open will receive SIGINT when the interrupt key is pressed. But mysql handles SIGINT and kills the running query, we don't want the wrapper to exit in that case. So, ignore SIGINT while mysql is running. This is similar to how a shell deals with this problem. The other options would have been: * Close the filehandles in PHP after forking (probably impossible) * Use pcntl_exec() so that PHP isn't running (more complicated and requires the pcntl extension anyway) * Clear termcap ISIG flag (probably would have broken mysql) Bug: T199152 Change-Id: I7660cd24e036fbe3fe36d12563ffe1c1fa2360d0 --- diff --git a/maintenance/mysql.php b/maintenance/mysql.php index 6d0882a64a..1b575bb28a 100644 --- a/maintenance/mysql.php +++ b/maintenance/mysql.php @@ -165,6 +165,12 @@ class MysqlMaintenance extends Maintenance { $args = array_merge( $args, $this->mArgs ); + // Ignore SIGINT if possible, otherwise the wrapper terminates when the user presses + // ctrl-C to kill a query. + if ( function_exists( 'pcntl_signal' ) ) { + pcntl_signal( SIGINT, SIG_IGN ); + } + $pipes = []; $proc = proc_open( Shell::escape( $args ), $desc, $pipes ); if ( $proc === false ) {