Hi. Code:
<?php
$window = new GtkWindow;
$window->set_size_request(200, 100);
$window->connect_simple('destroy', 'Gtk::main_quit');
$pid = pcntl_fork();
if ($pid == -1)
exit("Error\n");
else if ($pid)
echo "parent\n";
else
echo "child\n";
$window->show_all();
Gtk::main();
?>
Run: the program crashes and displays an error:
parent
child
The program 'index.php' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadIDChoice (invalid resource ID chosen for this connection)'.
(Details: serial 175 error_code 14 request_code 1 minor_code 0)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
index.php: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.0.
to use pcntl fork you need
<?php$pid = pcntl_fork();
if ($pid == -1){
exit("Error\n");
}else if ($pid){
echo "parent\n";
$window = new GtkWindow;
$window->set_size_request(200, 100);
$window->connect_simple('destroy', 'Gtk::main_quit');
$window->show_all();
Gtk::main();
}else{
echo "child\n";
}
?>