Skip to content

Processes are being terminated unexpectedly #52

Description

@petronetto

I'm not sure if I'm doing something wrong or if it's a bug, but when I run the code below, more often than not one or more tasks don't finish.

Fork::new()
    ->run(
        function () {
            foreach (range(1, 1000) as $i) {
                usleep(rand(300, 3000));
            }

            echo "## Done #1" . PHP_EOL;
        },
        function () {
            foreach (range(1, 1000) as $i) {
                usleep(rand(300, 3000));
            }

            echo "## Done #2" . PHP_EOL;
        },
        function () {
            foreach (range(1, 1000) as $i) {
                usleep(rand(300, 3000));
            }

            echo "## Done #3" . PHP_EOL;
        },
    );

I'm running on a MacBook with M2 chip using Docker, below the Dockerfile I run the tests:

FROM php:8.2-cli-bookworm as base

# Install system dependencies
RUN set -e \
  && apt update \
  && apt install -y \
    git \
    unzip \
    libzip-dev \
    procps \
    autoconf \
    automake \
    gcc \
    make \
    g++ \
    coreutils \
    libtool \
    libssl-dev \
    libpq-dev \
    libicu-dev \
    libpcre3-dev \
    zlib1g-dev

# Install igbinary extension
RUN pecl install -o -f igbinary \
  && rm -rf /tmp/pear \
  && docker-php-ext-enable igbinary

# Install Redis extension with igbinary support
RUN cd /tmp && git clone https://github.com/phpredis/phpredis.git \
    && cd phpredis \
    && phpize \
    && ./configure --enable-redis-igbinary \
    && make && make install \
    && docker-php-ext-enable redis

# Install PHP extensions
RUN docker-php-ext-install \
    intl \
    posix \
    sockets \
    pcntl \
    zip

# Install Composer globally
RUN curl https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Copy PHP configuration files
COPY docker/php/config/common/* /usr/local/etc/php/conf.d/

# Add source code into docker image
COPY . /app

WORKDIR /app

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions