HEX
Server: nginx/1.24.0
System: Linux localhost 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64
User: www (1000)
PHP: 8.3.27
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,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,imap_open,apache_setenv
Upload Files
File: /www/server/php/83/src/ext/sysvmsg/tests/005.phpt
--TEST--
sysvmsg functions on non-existing queue
--EXTENSIONS--
sysvmsg
--FILE--
<?php

$tests = array(null, 'foo');

foreach ($tests as $i => $q) {

    if ($q === null) {
        do {
            $id = ftok(__FILE__, chr(mt_rand(0, 255))); } while (msg_queue_exists($id));
    }

    $q = msg_get_queue($id) or die("Failed to create queue");
    msg_remove_queue($q) or die("Failed to close queue");

    echo "Iteration " . ($i + 1) . ":\n";

    $errno = 0;

    var_dump(msg_set_queue($q, array('msg_qbytes' => 1)));

    var_dump(msg_stat_queue($q));

    var_dump(msg_receive($q, 0, $null, 1, $msg, true, 0, $errno));
    var_dump($errno != 0);
    // again, but triggering an exception
    try {
        msg_receive($q, 0, $null, 0, $msg);
    } catch (ValueError $exception) {
        echo $exception->getMessage() . "\n";
    }

    var_dump(msg_send($q, 1, 'foo', true, true, $errno));
    var_dump($errno != 0);
}

echo "Done\n";
?>
--EXPECTF--
Iteration 1:
bool(false)
bool(false)
bool(false)
bool(true)
msg_receive(): Argument #4 ($max_message_size) must be greater than 0

Warning: msg_send(): msgsnd failed: Invalid argument in %s on line %d
bool(false)
bool(true)
Iteration 2:
bool(false)
bool(false)
bool(false)
bool(true)
msg_receive(): Argument #4 ($max_message_size) must be greater than 0

Warning: msg_send(): msgsnd failed: Invalid argument in %s on line %d
bool(false)
bool(true)
Done