Index: src/wp-includes/functions.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/wp-includes/functions.php	(revision 35784)
+++ src/wp-includes/functions.php	(revision )
@@ -2456,7 +2456,7 @@
 		$title = '';
 	}
 
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
+	if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
 		/**
 		 * Filter callback for killing WordPress execution for AJAX requests.
 		 *
Index: src/wp-cron.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/wp-cron.php	(revision 35784)
+++ src/wp-cron.php	(revision )
@@ -9,24 +9,67 @@
  * @package WordPress
  */
 
-ignore_user_abort(true);
+ignore_user_abort( true );
 
-if ( !empty($_POST) || defined('DOING_AJAX') || defined('DOING_CRON') )
-	die();
+if ( defined( 'DOING_AJAX' ) || defined( 'DOING_CRON' ) ) {
+	die( 'doing_ajax_or_doing_cron' );
+}
 
 /**
  * Tell WordPress we are doing the CRON task.
  *
  * @var bool
  */
-define('DOING_CRON', true);
+define( 'DOING_CRON', true );
 
-if ( !defined('ABSPATH') ) {
+if ( ! defined( 'ABSPATH' ) ) {
 	/** Set up WordPress environment */
 	require_once( dirname( __FILE__ ) . '/wp-load.php' );
 }
 
 /**
+ * Default handler for a WP Cron exit
+ *
+ * @param string $code
+ */
+function wp_cron_default_exit_handler( $code ) {
+	do_action( 'wp_cron_response_close', $code );
+	if ( 'bad_post_request_or_doing_ajax_or_doing_cron' === $code ) {
+		$response = 400;
+	} elseif ( 'empty_cron_array' === $code ) {
+		$response = 204;
+	} elseif ( 'no_scheduled_actions_due' === $code ) {
+		$response = 204;
+	} elseif ( 'cron_locked' === $code ) {
+		$response = 403;
+	} elseif ( 'cron_lock_check_fail' === $code ) {
+		$response = 400;
+	} elseif ( 'ok_exit_prematurely' === $code ) {
+		$response = 200;
+	} elseif ( 'ok' === $code ) {
+		$response = 200;
+	} else {
+		$response = 500;
+	}
+	if ( ! headers_sent() ) {
+		header( 'Content-Type: text/plain' );
+		status_header( $response );
+	}
+	wp_die( $code, '', compact( $response ) );
+}
+
+/**
+ * Filter callback for killing WordPress execution of WP_Cron.
+ *
+ * @param callable $wp_cron_exit_handler Callback function name.
+ */
+$wp_cron_exit_handler = apply_filters( 'wp_cron_exit_handler', 'wp_cron_default_exit_handler' );
+
+if ( ! empty( $_POST ) ) {
+	$wp_cron_exit_handler( 'bad_post_request' );
+}
+
+/**
  * Retrieves the cron lock.
  *
  * Returns the uncached `doing_cron` transient.
@@ -48,21 +91,24 @@
 		$value = wp_cache_get( 'doing_cron', 'transient', true );
 	} else {
 		$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", '_transient_doing_cron' ) );
-		if ( is_object( $row ) )
+		if ( is_object( $row ) ) {
 			$value = $row->option_value;
-	}
+		}
+	}
 
 	return $value;
 }
 
-if ( false === $crons = _get_cron_array() )
-	die();
+if ( false === $crons = _get_cron_array() ) {
+	$wp_cron_exit_handler( 'empty_cron_array' );
+}
 
 $keys = array_keys( $crons );
 $gmt_time = microtime( true );
 
-if ( isset($keys[0]) && $keys[0] > $gmt_time )
-	die();
+if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) {
+	$wp_cron_exit_handler( 'no_scheduled_actions_due' );
+}
 
 
 // The cron lock: a unix timestamp from when the cron was spawned.
@@ -70,14 +116,15 @@
 
 // Use global $doing_wp_cron lock otherwise use the GET lock. If no lock, trying grabbing a new lock.
 if ( empty( $doing_wp_cron ) ) {
-	if ( empty( $_GET[ 'doing_wp_cron' ] ) ) {
+	if ( empty( $_GET['doing_wp_cron'] ) ) {
 		// Called from external script/job. Try setting a lock.
-		if ( $doing_cron_transient && ( $doing_cron_transient + WP_CRON_LOCK_TIMEOUT > $gmt_time ) )
-			return;
+		if ( $doing_cron_transient && ( $doing_cron_transient + WP_CRON_LOCK_TIMEOUT > $gmt_time ) ) {
+			$wp_cron_exit_handler( 'cron_locked' );
+		}
 		$doing_cron_transient = $doing_wp_cron = sprintf( '%.22F', microtime( true ) );
 		set_transient( 'doing_cron', $doing_wp_cron );
 	} else {
-		$doing_wp_cron = $_GET[ 'doing_wp_cron' ];
+		$doing_wp_cron = $_GET['doing_wp_cron'];
 	}
 }
 
@@ -85,27 +132,57 @@
  * The cron lock (a unix timestamp set when the cron was spawned),
  * must match $doing_wp_cron (the "key").
  */
-if ( $doing_cron_transient != $doing_wp_cron )
-	return;
+if ( $doing_cron_transient != $doing_wp_cron ) {
+	$wp_cron_exit_handler( 'cron_lock_check_fail' );
+}
 
+/**
+ * Fires before looping through all the scheduled hooks to filter out those that don't need to run yet.
+ *
+ * @param array $crons The scheduled hooks.
+ */
+do_action( 'wp_cron_before_crons_loop', $crons );
 foreach ( $crons as $timestamp => $cronhooks ) {
-	if ( $timestamp > $gmt_time )
+	if ( $timestamp > $gmt_time ) {
 		break;
+	}
 
+	/**
+	 * Fires before looping through the scheduled hooks of a timestamp.
+	 *
+	 * @param array $cronhooks The scheduled hooks of a specific timestamp.
+	 */
+	do_action( 'wp_cron_before_cronhooks_loop', $cronhooks );
 	foreach ( $cronhooks as $hook => $keys ) {
 
+		/**
+		 * Fires before looping through the scheduled hook's keys.
+		 *
+		 * @param array $keys The scheduled hook's keys.
+		 */
+		do_action( 'wp_cron_before_keys_loop', $keys );
 		foreach ( $keys as $k => $v ) {
 
 			$schedule = $v['schedule'];
 
 			if ( $schedule != false ) {
-				$new_args = array($timestamp, $schedule, $hook, $v['args']);
+				$new_args = array( $timestamp, $schedule, $hook, $v['args'] );
-				call_user_func_array('wp_reschedule_event', $new_args);
+				call_user_func_array( 'wp_reschedule_event', $new_args );
 			}
 
 			wp_unschedule_event( $timestamp, $hook, $v['args'] );
 
 			/**
+			 * Fires before a scheduled hook is fired.
+			 *
+			 * @param string $hook Name of the hook that was scheduled to be fired.
+			 * @param array $args The arguments to be passed to the hook.
+			 * @param string $schedule The interval which the scheduled hook runs at.
+			 * @param int $timestamp The timestamp of when the hook was scheduled to fire.
+			 */
+			do_action( 'wp_cron_before_hook', $hook, $v['args'], $schedule, $timestamp );
+
+			/**
 			 * Fires scheduled events.
 			 *
 			 * @ignore
@@ -114,16 +191,48 @@
 			 * @param string $hook Name of the hook that was scheduled to be fired.
 			 * @param array  $args The arguments to be passed to the hook.
 			 */
- 			do_action_ref_array( $hook, $v['args'] );
+			do_action_ref_array( $hook, $v['args'] );
 
+			/**
+			 * Fires after a scheduled hook is fired.
+			 *
+			 * @param string $hook Name of the scheduled hook that fired.
+			 * @param array $args The arguments passed to the hook.
+			 * @param string $schedule The interval which the scheduled hook ran at.
+			 * @param int $timestamp The timestamp of when the hook was scheduled to fire.
+			 */
+			do_action( 'wp_cron_after_hook', $hook, $v['args'], $schedule, $timestamp );
+
 			// If the hook ran too long and another cron process stole the lock, quit.
-			if ( _get_cron_lock() != $doing_wp_cron )
-				return;
+			if ( _get_cron_lock() != $doing_wp_cron ) {
+				$wp_cron_exit_handler( 'ok_exit_prematurely' );
-		}
-	}
+			}
+		}
+
+		/**
+		 * Fires after looping through the scheduled hook's keys.
+		 *
+		 * @param array $keys The scheduled hook's keys.
+		 */
+		do_action( 'wp_cron_after_keys_loop', $keys );
-}
+	}
 
-if ( _get_cron_lock() == $doing_wp_cron )
+	/**
+	 * Fires after looping through the scheduled hooks of a timestamp.
+	 *
+	 * @param array $cronhooks The scheduled hooks of a specific timestamp.
+	 */
+	do_action( 'wp_cron_after_cronhooks_loop', $cronhooks );
+}
+/**
+ * Fires before looping through all the scheduled hooks to filter out those that don't need to run yet.
+ *
+ * @param array $crons The scheduled hooks.
+ */
+do_action( 'wp_cron_after_crons_loop', $crons );
+
+if ( _get_cron_lock() == $doing_wp_cron ) {
 	delete_transient( 'doing_cron' );
+}
 
-die();
+$wp_cron_exit_handler( 'ok' );
