Skip to content

Clarify when fibers can be switched #2390

@Provoker

Description

@Provoker

Description

Since version 8.2.0 when trying to create fiber in a function passed to pcntl_signal an "Cannot switch fibers in current execution context" error occurs.
The documentation says only about limitation in the destructor.

The following code:

<?php

pcntl_signal(SIGINT, function () {
	$fiber = new Fiber(function () {
		Fiber::suspend('test');
	});

	var_dump($fiber->start());
});

posix_kill(getmypid(), SIGINT);
pcntl_signal_dispatch();

Resulted in this output:

string(4) "test"

But I expected this output instead:

Uncaught FiberError: Cannot switch fibers in current execution context

PHP Version

PHP 8.2.0

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Category: FibersbugDocumentation contains incorrect informationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions