Annotation of embedaddon/php/ext/pcntl/tests/001.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test pcntl wait functionality
! 3: --SKIPIF--
! 4: <?php
! 5: if (!extension_loaded("pcntl")) print "skip";
! 6: elseif (!function_exists("posix_kill")) print "skip posix_kill() not available";
! 7: ?>
! 8: --FILE--
! 9: <?php
! 10: function test_exit_waits(){
! 11: print "\n\nTesting pcntl_wifexited and wexitstatus....";
! 12:
! 13: $pid=pcntl_fork();
! 14: if ($pid==0) {
! 15: sleep(1);
! 16: exit(-1);
! 17: } else {
! 18: $options=0;
! 19: pcntl_waitpid($pid, $status, $options);
! 20: if ( pcntl_wifexited($status) ) print "\nExited With: ". pcntl_wexitstatus($status);
! 21: }
! 22: }
! 23:
! 24: function test_exit_signal(){
! 25: print "\n\nTesting pcntl_wifsignaled....";
! 26:
! 27: $pid=pcntl_fork();
! 28:
! 29: if ($pid==0) {
! 30: sleep(10);
! 31: exit;
! 32: } else {
! 33: $options=0;
! 34: posix_kill($pid, SIGTERM);
! 35: pcntl_waitpid($pid, $status, $options);
! 36: if ( pcntl_wifsignaled($status) ) {
! 37: $signal_print=pcntl_wtermsig($status);
! 38: if ($signal_print==SIGTERM) $signal_print="SIGTERM";
! 39: print "\nProcess was terminated by signal : ". $signal_print;
! 40: }
! 41:
! 42: }
! 43: }
! 44:
! 45:
! 46: function test_stop_signal(){
! 47: print "\n\nTesting pcntl_wifstopped and pcntl_wstopsig....";
! 48:
! 49: $pid=pcntl_fork();
! 50:
! 51: if ($pid==0) {
! 52: sleep(1);
! 53: exit;
! 54: } else {
! 55: $options=WUNTRACED;
! 56: posix_kill($pid, SIGSTOP);
! 57: pcntl_waitpid($pid, $status, $options);
! 58: if ( pcntl_wifstopped($status) ) {
! 59: $signal_print=pcntl_wstopsig($status);
! 60: if ($signal_print==SIGSTOP) $signal_print="SIGSTOP";
! 61: print "\nProcess was stoped by signal : ". $signal_print;
! 62: }
! 63: posix_kill($pid, SIGCONT);
! 64: }
! 65: }
! 66:
! 67: print "Staring wait.h tests....";
! 68: test_exit_waits();
! 69: test_exit_signal();
! 70: test_stop_signal();
! 71: ?>
! 72: --EXPECT--
! 73: Staring wait.h tests....
! 74:
! 75: Testing pcntl_wifexited and wexitstatus....
! 76: Exited With: 255
! 77:
! 78: Testing pcntl_wifsignaled....
! 79: Process was terminated by signal : SIGTERM
! 80:
! 81: Testing pcntl_wifstopped and pcntl_wstopsig....
! 82: Process was stoped by signal : SIGSTOP
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>