Skip to content
Advertisement

Message queue: msgsnd failed : Invalid argument

Can anyone please help me to point out as what is the error in my program?

Thanks in advance, kingsmasher1

JavaScript

Output: msgsnd failed: Invalid argument

Advertisement

Answer

You do not have enough space in your buf.mtext (15 characters) for "This is a test message" (23 characters plust one more for a NUL terminator).

I’d say there’s a good chance that may be corrupting your type or even some other piece of information on the stack (like msqid or length or key).

Whether that’s the actual problem or not, it’s still undefined behaviour and should be fixed. The first thing I’d do is check by replacing:

JavaScript

with:

JavaScript

to see if it fixes it.

Alternatively, make mtext big enough to store the data you’re putting in there.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement