Forum > Unix

msgrcv only succeeds if msgsnd sends a buffer with only zeros.

(1/5) > >>

TCH:
I have two processes, which have these lines:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---msgp.mtype := 1;e := msgsnd(msqid, @msgp, 4, IPC_NOWAIT);and
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---sz := msgrcv(msqid, @msgp, 4, 1, IPC_NOWAIT);The variable msgp is the type of
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type mymsg1 = record        mtype: longword;        mtext: array[0..7] of byte;end;Now, msgsnd() always reports no problems, that the buffer is sent. However, msgrcv() always gives back -1 with errno of ESysENOMSG, except if the first four byte of msgp.mtext are zeros. Then it succeeds, else it fails. Regardless the size of the sent buffer.

The very same algorithm and code works flawlessly with C. Any ideas?

TCH:
No ideas?

MarkMLl:
What library are you using? How is the socket opened?

Give us a compilable example to demonstrate the problem.

MarkMLl

marcov:

* OS
* compiler target and version
* c code
* pascal code

MarkMLl:
If we really are obliged to read minds, I suggest that https://linux.die.net/man/2/msgrcv might be relevant, which *explicitly* says:


--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---The msgp argument is a pointer to caller-defined structure of the followinggeneral form:     struct msgbuf {        long mtype;       /* message type, must be > 0 */        char mtext[1];    /* message data */    }; The mtext field is an array (or other structure) whose size is specified bymsgsz, a nonnegative integer value. Messages of zero length (i.e., nomtext field) are permitted. The mtype field must have a strictly positiveinteger value. This value can be used by the receiving process for messageselection (see the description of msgrcv() below).  
MarkMLl

Navigation

[0] Message Index

[#] Next page

Go to full version