Segmentation fault on PROCESS STATUS CHANGES

Issue #8 wontfix
Former user created an issue

Hi

When I try the code from your examples I am getting Segmentation fault. ev version is 0.2.10 compiled under lampp php 5.5.9

EXAMPLE CODE

$pid = pcntl_fork();

if ($pid == -1) {
    fprintf(STDERR, "pcntl_fork failed\n");
} elseif ($pid) {
    $w = new EvChild($pid, FALSE, function ($w, $revents) {
        $w->stop();

        printf("Process %d exited with status %d\n", $w->rpid, $w->rstatus);
    });

    Ev::run();

    // Protect against Zombies
    pcntl_wait($status);
} else {
    //Forked child
    exit(2);
}

Comments (3)

  1. Ruslan Osmanov repo owner

    I can't reproduce this bug. However, you mention "lamp". Did you run this code under Apache SAPI? The extension is really intended for CLI SAPI only!

    bug.php

    <?php
    $pid = pcntl_fork();
    if ($pid == -1) {
      fprintf(STDERR, "pcntl_fork failed\n");
    } elseif ($pid) {
      $w = new EvChild($pid, FALSE, function ($w, $revents) {
        $w->stop();
        printf("Process %d exited with status %d\n", $w->rpid, $w->rstatus);
    });
    
    Ev::run();
    
    // Protect against Zombies
    pcntl_wait($status);
    } else { //Forked child
      exit(2);
    }
    

    How I run it from CLI

    $ php -n -dextension=ev.so bug.php
    Process 12059 exited with status 512
    

    My PHP version

    $ php --version
    PHP 5.5.10-pl0-gentoo (cli) (built: Mar 22 2014 23:07:23) (DEBUG)
    Copyright (c) 1997-2014 The PHP Group
    Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
        with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
    
  2. Log in to comment