"Fossies" - the Fresh Open Source Software Archive

Member "hhvm-HHVM-4.165.0/hphp/test/zend/good/ext/pcntl/tests/001.php" (22 Jul 2022, 1682 Bytes) of package /linux/www/hhvm-HHVM-4.165.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?hh
    2 function test_exit_waits(){
    3     print "\n\nTesting pcntl_wifexited and wexitstatus....";
    4 
    5     $pid=pcntl_fork();
    6     if ($pid==0) {
    7         sleep(1);
    8         exit(-1);
    9     } else {
   10         $options=0;
   11         $status = null;
   12         pcntl_waitpid($pid, inout $status, $options);
   13         if ( pcntl_wifexited($status) ) print "\nExited With: ". pcntl_wexitstatus($status);
   14     }
   15 }
   16 
   17 function test_exit_signal(){
   18     print "\n\nTesting pcntl_wifsignaled....";
   19 
   20     $pid=pcntl_fork();
   21 
   22     if ($pid==0) {
   23         sleep(10);
   24         exit;
   25     } else {
   26         $options=0;
   27         posix_kill($pid, SIGTERM);
   28         $status = null;
   29         pcntl_waitpid($pid, inout $status, $options);
   30         if ( pcntl_wifsignaled($status) ) {
   31             $signal_print=pcntl_wtermsig($status);
   32             if ($signal_print==SIGTERM) $signal_print="SIGTERM";
   33             print "\nProcess was terminated by signal : ". $signal_print;
   34         }
   35 
   36     }
   37 }
   38 
   39 
   40 function test_stop_signal(){
   41     print "\n\nTesting pcntl_wifstopped and pcntl_wstopsig....";
   42 
   43     $pid=pcntl_fork();
   44 
   45     if ($pid==0) {
   46         sleep(1);
   47         exit;
   48     } else {
   49         $options=WUNTRACED;
   50         posix_kill($pid, SIGSTOP);
   51         $status = null;
   52         pcntl_waitpid($pid, inout $status, $options);
   53         if ( pcntl_wifstopped($status) ) {
   54             $signal_print=pcntl_wstopsig($status);
   55             if ($signal_print==SIGSTOP) $signal_print="SIGSTOP";
   56             print "\nProcess was stoped by signal : ". $signal_print;
   57         }
   58         posix_kill($pid, SIGCONT);
   59     }
   60 }
   61 <<__EntryPoint>> function main(): void {
   62 print "Staring wait.h tests....";
   63 test_exit_waits();
   64 test_exit_signal();
   65 test_stop_signal();
   66 }