Page 1 of 1

pcntl fork and standart output

Posted: Mon Sep 20, 2010 5:14 am
by ebl
i run this code on lighttp server

Code: Select all

	$pid = pcntl_fork();
	if ($pid == -1) {
	     die('could not fork');
	} else if ($pid) {
		pcntl_wait($status,WNOHANG);
		$fp = fopen("tmp","a");
	 	fwrite($fp,"parent");
	 	fclose($fp);
		echo " back to parent ";
	 } else {
	 	$fp = fopen("tmp","a");
	 	fwrite($fp,"sun ");
	 	fclose($fp);
		echo " sun ";
		
	}

and i get the following output:
on the screen i get only "sun"
and on the tmp file i get "sun parent"

how can i get the parent to continue output?

thanks