Statement on glibc/iconv Vulnerability

sapi_windows_generate_ctrl_event

(PHP 7 >= 7.4.0, PHP 8)

sapi_windows_generate_ctrl_eventBelirtilen sürece bir CTRL olayı gönderir

Açıklama

sapi_windows_generate_ctrl_event(int $olay, int $pid = 0): bool

Aynı süreç grubundaki başka bir sürece belirtilen CTRL olayını gönderir.

Bağımsız Değişkenler

olay

Önderilecek CTRL olayı; PHP_WINDOWS_EVENT_CTRL_C veya PHP_WINDOWS_EVENT_CTRL_BREAK olabilir.

pid

Olayın gönderileceği sürecin kimliği. 0 belirtilirse olay süreç grubundaki tüm süreçlere gönderilir.

Dönen Değerler

Başarı durumunda true, başarısızlık durumunda false döner.

Örnekler

Örnek 1 - sapi_windows_generate_ctrl_event() örneği

Bu örnek, CTRL+BREAK olaylarının bir alt sürece nasıl iletileceğini gösterir. Bu durumda, kullanıcı CTRL+BREAK tuşlarına basıp süreci sonlandırana kadar kadar süreç her saniye Hala etkinim dizgesini çıktılar.

<?php
// çocuk süreçlere CTRL+BREAK olaylarını ilet
sapi_windows_set_ctrl_handler('sapi_windows_generate_ctrl_event');

// Her saniye bir çıktı verecek bir süreç oluştur
$cmd = ['php', '-r', 'while (true) { echo "Hala etkinim\n"; sleep(1); }'];
$descspec = array(['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']);
$options = ['create_process_group' => true];
$proc = proc_open($cmd, $descspec, $pipes, null, null, $options);
while (
true) {
echo
fgets($pipes[1]);
}
?>

Ayrıca Bakınız

add a note

User Contributed Notes 1 note

up
1
Michael Q
3 years ago
This function may produce a Warning:

sapi_windows_set_ctrl_handler(): CTRL events trapping is only supported on console in script.php..

It happens when script is started by "php-cgi.exe", so "php.exe -q" should be used instead.

While pressing CTRL+C don't expect the handler to run instantly, i've ran some curl request in a loop and found that handler runs when either response arrives or request finishes by timeout.
To Top